67 posts
  • Has been part of the Envato Community for over 2 years
  • Has collected 1+ items on Envato Market
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
  • Has referred 100+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+2 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)

67 posts
  • Has been part of the Envato Community for over 2 years
  • Has collected 1+ items on Envato Market
mattmatt88 says

Works. Thank you very much.

by
by
by
by
by
by