Are you want to load the parent category templates on the sub categories also? Add the following code to the functions.php file of your current activated theme or you can also add the below code inside your site-specific plugin.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | /** * Force sub categories to use parent category templates. */ function fwm_force_use_parent_category_template() { $category = get_queried_object(); $templates = array(); // Add default category template files $templates[] = "category-{$category->slug}.php"; $templates[] = "category-{$category->term_id}.php"; if ( $category->category_parent != 0 ) { $parent = get_category( $category->category_parent ); if ( !empty($parent) ) { $templates[] = "category-{$parent->slug}.php"; $templates[] = "category-{$parent->term_id}.php"; } } $templates[] = 'category.php'; return locate_template( $templates ); } add_filter( 'category_template', 'fwm_force_use_parent_category_template' ); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.