corsonr
12/6/2012 - 8:43 AM

Custom Query CPT + posts in same categories

Custom Query CPT + posts in same categories

<?php
// Create the Query
$posts_per_page = -1;
$post_type 		= array('post','your_cpt_here');
$categories_id 	= array( 'ID' ); 
$orderby 		= 'menu_order';
$order 			= 'ASC';
$paged 			= (get_query_var('paged')) ? get_query_var('paged') : 1;
			
$query = new WP_Query( array ( 
							'post_type'      => $post_type,
							'cat' 			 => $categories_id,
							'posts_per_page' => $posts_per_page,
							'orderby'        => $orderby, 
							'order'          => $order,
							'paged'          => $paged
							) 
					);

//Get post type count
$post_count = $query->post_count;
$i = 1;

// Displays info
if( $post_count > 0) :

	// Loop
	while ($query->have_posts()) : $query->the_post();
	
	/* do your stuff here */
	
	endwhile;

endif;