Edit
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';
...and...
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:
- By default, custom post types have no registered/supported taxonomies, including the
category
taxonomy.
- 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:
Add 'category'
to the array of taxonomies supported by the custom post type, via the 'taxonomies'
parameter of the register_post_type()
arguments array:
register_post_type(
'tribe_events',
array(
'taxonomies' => array( 'category' )
)
);
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:
- Your question is misleading, because you indicate that you want to use the
'category'
taxonomy in your query
- 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".