Hi,
I want to use a custom post type in a native WP category,
When i use this code, it works. I can build my template using a category and my CPT show how they should, But the template won’t appear on the front end. It reverts all archives to the generic cat templates (for every category). Almost as if this code removes any template conditions.
Any gleaming reasons why ? Thanks
add_filter('pre_get_posts', 'query_post_type');
function query_post_type($query) {
if( is_category() ) {
$post_type = get_query_var('post_type');
if($post_type)
$post_type = $post_type;
else
$post_type = array('nav_menu_item', 'post', 'bonus');
$query->set('post_type',$post_type);
return $query;
}
}