67 posts
  • Bought between 1 and 9 items
  • Has been a member for 2-3 years
mattmatt88 says

Hello.

I haven’t found the right thing with google. But I think you can easily answer that:

I have added a custom post type: name: “portfolio” registered taxonomy for the category: “portfolio_category”

On the Front Page I want the latest portfolio items of a SPECIFIC CATEGORY (e.g. ID 5 ) to be displayed, but it doesn’t work with the normal “cat” like in the example below. It’s also not possible to write “portfolio_category” instead of “cat”.

new WP_Query('post_type=portfolio'.'&cat=5...

How can I fix that?

Thank you

101 posts
  • Elite Author
  • Referred between 100 and 199 users
  • Bought between 1 and 9 items
  • Has been a member for 3-4 years
  • Exclusive Author
  • Sold between 100 000 and 250 000 dollars
PixelBook says

Try something like

$args=array("post_type" => "portfolio","tax_query" => array(array("taxonomy" => "portfolio_category","field" => "id","terms" => $cat)));
query_posts($args);

while ( have_posts() ) : the_post();
....
endwhile;   
wp_reset_query(); 
 

where $cat is an array. In your case array(5)

67 posts
  • Bought between 1 and 9 items
  • Has been a member for 2-3 years
mattmatt88 says

Works. Thank you very much.

by
by
by
by
by
by