82 posts
  • 3 Years of Membership
  • Austria
  • Collector Level 1
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
  • Weekly Top Seller
  • Elite Author
  • 4 Years of Membership
  • Affiliate Level 4
+3 more
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)

82 posts
  • 3 Years of Membership
  • Austria
  • Collector Level 1
mattmatt88
says

Works. Thank you very much.

by
by
by
by
by
by