Include custom post types in categories widget

I have an ‘actor’ cpt and it seems to automatically get added to the query:

SELECT object_id, term_taxonomy_id
FROM wp_term_relationships INNER JOIN wp_posts ON object_id = ID 
WHERE term_taxonomy_id IN (38,40,30,11,32,34,29,39,35,9,31,19,33,37,42,41,27,25,36,1,26) 
AND post_type IN ('post', 'actor')
AND post_status="publish"

Call from: require, require_once, include, get_sidebar, get_template_part, locate_template, load_template, require, dynamic_sidebar, call_user_func_array, WP_Widget->display_callback, WP_Widget_Categories->widget, wp_list_categories, get_categories, get_terms, _pad_term_counts

(Using the Debug Queries plugin)

And this is the CPT definition:

register_post_type('actor', array(
  'public' => true,
  'labels' => $labels,
  'has_archive' => 'actors',
  'taxonomies' => array( 'category' )
));

Leave a Comment