home ~ custom post type not supporting default category

custom post type not supporting default category

For custom post type not supporting default category

Use this code on functions.php at the bottom:

function add_custom_types_to_tax( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars[‘suppress_filters’] ) ) {

// Get all your post types
// $post_types = get_post_types();
$post_types = array( ‘post’, ‘course’ );

$query->set( ‘post_type’, $post_types );
return $query;
}
}
add_filter( ‘pre_get_posts’, ‘add_custom_types_to_tax’ );

काक चेष्टा, बको ध्यानं, श्वान निंद्रा तथैव च । अल्पाहारी, सदाचारी एतद विद्यार्थिन पंच लक्षणं ।।...read more

signature

Quote Of The Day