Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a custom post type 'Events' created by The Event Calendar plugin. It has registered it's own custom taxonomy. Is there a way I can assign the regular WP post categories to some of these events so that they will show up on category archives?

I see in the answer to this question get_posts cannot grab from specific category that I have to add 'category' to the array of taxonomies supported by the Events post type, something like this:

register_post_type( 'tribe_events', array( 'taxonomies' => array( 'category' ) ) );

What is the next step I have to take to get this to work?

share|improve this question
    
This question is hard to understand, regular post categories will already show up for category archives, what do you mean by assign. –  Wyck Jun 26 '13 at 4:23
    
So you want to allow Events to share a taxonomy with regular posts? –  Pat J Jun 26 '13 at 4:25
    
Exactly, I need the Events posts to share the regular posts taxonomy. –  Chris Jun 28 '13 at 15:49

1 Answer 1

You can use register_taxonomy_for_object_type() to use a taxonomy with a post type, without having to touch the post type registration code, example:

function wpa_categories_for_events(){
    register_taxonomy_for_object_type( 'category', 'tribe_events' );
}
add_action( 'init', 'wpa_categories_for_events' );

To have events appear on the category pages, I believe you have to modify the default category queries via pre_get_posts to add custom post types, by default they only query the post post type.

function wpa_events_on_category_pages( $query ) {
    if ( $query->is_category() && $query->is_main_query() ) {
        $query->set( 'post_type', array( 'post', 'tribe_events' ) );
    }
}
add_action( 'pre_get_posts', 'wpa_events_on_category_pages' );
share|improve this answer

Your Answer

 
discard

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.