80 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
+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)

80 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.

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by