jcadima
3/1/2016 - 4:54 PM

CASAL - Get specific Category posts from custom post type TR_PORTFOLIO PLUGIN

CASAL - Get specific Category posts from custom post type TR_PORTFOLIO PLUGIN


<?php
/*
- we have these categories created for this custom post type:
  featured-properties, general, industrial
- we have a custom post type: tr_portfolio
- we only need to retrieve the posts where the category is: featured-properties
- post per page is irrelevant
- terms is the key that decides the specific category we want
*/
// HOME PAGE, SHOW ONLY THE 3 'featured-properties' 
// ( 3 properties are only checked, no other category needs to be checked)
$loop = new WP_Query(array('taxonomy' => 'tr_portfolio_taxonomy', 
						   'post_type' => 'tr_portfolio',
						   'posts_per_page' => 3,
					   'tax_query' => array( array( 'taxonomy' => 'tr_portfolio_taxonomy', 
													 'field' => 'slug', 
													 'terms' => 'featured-properties' 
													              )  
											           )	
						              )  
				            ); 	


// MAIN INDEX  ( LIST ALL PROPERTIES )
$args = array('post_type' => 'tr_portfolio', 
					   'posts_per_page' => 20					  
		         );
			  
$properties = new WP_Query($args);