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?

  • 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

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' );
  • Exactly what I was looking for too, but it also screws up the table display in the modern tribe calendar "Edit Events" admin page, by adding an extra column. I'm a WP tyro and haven't a clue how to address that problem. Any clues? – jjon Apr 26 '18 at 0:25
  • FYI (work-around): The 'Events' table in admin is only designed to accommodate a maximum of 8 columns so if you add the 'categories' column using these functions, the layout of the table is distorted. Fortunately, 'Screen Options' allows you to choose which columns to display, so you can just de-select one. (duh!) – jjon Apr 26 '18 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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