I want to use different template for posts of all subcategory of one category. Below is the Code I am using :
add_filter( 'single_template', 'get_custom_cat_template' ) ;
function get_custom_cat_template( $single_template ) {
global $post;
if ( is_category( 'blog' ) || in_category( 'blog' ) ) {
$single_template = dirname( __FILE__ ) . '/single-blog.php';
}
return $single_template;
}
Here "blog" is the category. This code is working for parent category (blog) only. For posts of subcategory, it is loading default single.php
file.
How can I change the code so that it works for all subcategories of parent category?