plugins – Adding custom post category to categories widget


I’m using a plugin called The Events Calendar, which is creating a custom post type called tribe_events. It also lets me assign categories and add the posts to the main loop. Now I’m trying to get these custom post categories to show up in the standard category filter widget in the sidebar on my blog posts page. What I imagine would look something like this:


  • News (14)
  • Special Deals (5)
  • Events (8)

The “News” and “Special Deals” here would be regular blog categories, and “Events” is a category for the custom post type. (I just have one category there, so if it’s easier to add the custom posts to a blog category rather than adding the category to the list of categories the widget accepts, that would be just fine.) How do I get the widget in the sidebar to list my “Events” category?

I tried using the function mentioned here (under “Displaying Multiple Post Types on Category Page”) and replaced “movies” with “tribe_events,” but I’m not sure if this would be the right solution or if I did it right, and it doesn’t work for the widget. This is my function:

add_filter('pre_get_posts', 'query_post_type');
function query_post_type($query) {
  if( is_category() ) {
    $post_type = get_query_var('post_type');
        $post_type = $post_type;
        $post_type = array('nav_menu_item', 'post', 'tribe_events');
    return $query;

user204381 2 years 2021-04-24T17:37:08-05:00 0 Answers 0 views 0

Leave an answer