in my site i have many category and subcategory (child category)
say like my one category name
Printing
- 4 color
- 2 color
- offset print
Exmple i want when visit 4 color category page it will show all 4 color category post with particular template. i tried many code but not is actually give me perfect result. bellow is one which is used it is work nice but now issue is it also effect on other category child also.
add_action('template_redirect', 'load_category_tree_template');
function load_category_tree_template() {
if (is_category() && !is_feed()) {
// replace 'your-base-category-slug' with the slug of root category
$base_tree_cat_id = get_cat_id('printing-products');
// get current category id
$catid = get_query_var('cat');
if (is_category($base_tree_cat_id) || cat_is_ancestor_of($base_tree_cat_id, $catid)) {
load_template(STYLESHEETPATH . 'category-printing.php');
exit;
}
}
}