Wordpress pre_get_posts category filter removes custom menu items
You may try this (No need for multiple if
and $post_type = $post_type;
)
add_filter('pre_get_posts', 'query_post_type');
function query_post_type($query) {
if(is_category() && $query->is_main_query()) {
$query->set( 'post_type', array( 'post', 'Blog' ) );
}
return $query;
}
check this conditions before your stuff :
if ($query->get('post_type') == 'nav_menu_item')
return $query;
like here :
function wp32151_search_filter($query)
{
if ($query->get('post_type') == 'nav_menu_item')
return $query;
if ($query->is_search) {
$query->set('post_type', 'shows');
}
return $query;
}
add_filter('pre_get_posts', 'wp32151_search_filter');