WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using get_posts to grab list of posts from custom post_type. I also want list to be limited to specific category. So I tried:

$postslist = get_posts('order=ASC&orderby=date&posts_per_page=4&post_type=tribe_events&category_name=Gudauri');

This displays nothing, if I remove category_name=Gudauri it lists all posts from custom post type tribe_events.

What am I doing wrong? I also tried category=id but with no luck!

share|improve this question


In response to OP's answer:

So you use post_type and add cat at the end. Like [tribe_events][_cat]=[value]

This is absolutely incorrect. WordPress does not automatically create custom taxonomies in this manner.

From the OP's comment:

I'm using tribe Events calendar. Check it there.

Here is the relevant PHP file from the The Events Calendar Plugin. And here are the key lines of code:

const TAXONOMY = 'tribe_events_cat';
const POSTTYPE = 'tribe_events';


register_taxonomy( self::TAXONOMY, self::POSTTYPE, array( /**snipped*/));

As suspected: the Plugin is registering a custom post type, and then registering a custom taxonomy to use for that custom post type.

Original Answer

So, you've registered a custom post type, 'tribe_events'. Two important points:

  1. By default, custom post types have no registered/supported taxonomies, including the category taxonomy.
  2. By default, the 'category' taxonomy is only registered/supported by the 'post' post-type.

In order to use the 'category' taxonomy for a custom post type, you need to do one of two things:

  1. Add 'category' to the array of taxonomies supported by the custom post type, via the 'taxonomies' parameter of the register_post_type() arguments array:

            'taxonomies' => array( 'category' )
  2. Add 'category' taxonomy support for the custom post type, via register_taxonomy_for_object_type():

    register_taxonomy_for_object_type( 'category', 'tribe_events' );

Regarding your proposed "solution"

From your answer:

So you use post_type and add cat at the end. Like [tribe_events][_cat]=[value]

I know of absolutely nothing in core that would auto-create a {post-type}_cat taxonomy, or that would equate a {post-type}_cat taxonomy to the category taxonomy.

What I suspect is happening here is that you've registered a custom 'tribe_events_cat' taxonomy, and then added that custom taxonomy to your custom post type, via the 'taxonomies' parameter in register_post_type().

If this is the case, then:

  1. Your question is misleading, because you indicate that you want to use the 'category' taxonomy in your query
  2. I would strongly recommend getting in the habit of referring to a custom taxonomy as a taxonomy, rather than as a category. "Category" is a taxonomy; not all taxonomies are "category".
share|improve this answer
I didn't do anything, I'm using tribe events calendar. So I was guessing how authors of the plugin implemented it. I accidentally discovered how to display posts by going through stackoverflow topics. – Sandro Dzneladze Aug 30 '12 at 21:01
up vote -1 down vote accepted

I figured it out, it appears correct syntax for custom post types is this:

$postslist = get_posts('order=ASC&orderby=date&posts_per_page=4&post_type=tribe_events&tribe_events_cat=Gudauri');

note: post_type=tribe_events&tribe_events_cat=Gudauri

So you use post_type and add cat at the end. Like [tribe_events][_cat]=[value]

share|improve this answer
I don't believe this answer is correct. Can you please post your register_post_type() and (if applicable) register_taxonomy() code? – Chip Bennett Aug 19 '12 at 12:29
@ChipBennett I'm using tribe Events calendar. Check it there. – Sandro Dzneladze Sep 16 '12 at 10:02
Yes, this answer is definitely not correct. The Plugin registers a custom taxonomy, tribe_events_cat. I'll update my answer. – Chip Bennett Sep 16 '12 at 13:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.