Is it possible to have multiple custom post types appear on a category page?
For example, I have a category Animals and I can assign it to both these custom post types: dog, cat
Both cpts use a pre_get_posts filter:
function dog_query_post_type($query) {
if( is_category() && $query->is_main_query() && empty( $query->query_vars['suppress_filters'] ) ) {
$post_type = get_query_var('post_type');
if($post_type)
$post_type = $post_type;
else
$post_type = array( 'post', 'dog', 'nav_menu_item');
$query->set('post_type',$post_type);
return $query;
}
}
add_filter('pre_get_posts', 'dog_query_post_type');
But only one cpt will appear on the Animals category page.
If I deactivate the plugin for the dogs cpt, then any cat cpts assigned to Animals will appear on the category page.
I have tried changing the priority settings on the add_filter calls.
And none of this affects the display of normal posts in the category from appearing on the category page.
I'd like to have any post, of any type, appear on the Animals page.
What am I missing?