There are two functions you need to accomplish this. First, you will have to know whether a category is a subactegory of 16. This is cat_is_ancestor_of
. Second, you will have to force that category to use the template of 16, which you do with locate_template
. Knowing this, you can build a filter on the function that determines which template to use for a category page like this:
add_filter ('category_template', 'wpse24089_category_template');
function wpse24089_category_template( $template ) {
$current_cat = get_queried_object_id();
if (cat_is_ancestor_of (16, $current_cat))
$template = locate_template( 'category-slider.php' );
return $template;
}
Related Posts:
- Show posts from all categories
- is_archive() content being shown instead of is_category()
- Edit the markup of categories list
- How to get data about category in category.php
- editing fonts of category links from the_category() funtion
- How to check category of of custom post type or not
- Different templates for different category tags
- How to differentiate the homepage structure from the category page structure in WordPress template?
- How to list posts from a sub-category that is listed in a parent category (more details below)?
- Choosing different templates for categories
- altering theme – content generated by PAGES not PORTFOLIO
- Check if current category has subcategories
- wp_nav_menu not appearing for a couple pages
- Preventing index.php?category_name=something from redirecting
- Make all subcategories use the template of its category parent?
- wp_update_nav_menu_item() to insert categories
- How can I get wp_head() as a string instead of echoing it?
- How to create a widgetized sidebar for every category dynamically?
- Display only deepest category on a single post?
- How do I set a specific template for sub-categories?
- Template tags to display custom post type posts in category template?
- List Categories of the Parent Category of the Current Category
- Why adding Categories does not auto refresh in Backend while using my custom theme?
- Returning Variables back into a template
- How to control template resolution if both Author and Category filter in place?
- Which php file lists all the post of a category
- Apply custom category template to subcategories
- How do I make the category template display full posts instead of partial posts?
- get_query_var() and permalinks
- Single_cat_title() print the title before text
- Retrieve all posts within tag OR category?
- Code to pull in a PHP file named after the category ID
- New Theme creation
- Are Category or Tag Archive Pages Possible?
- Possible to make a subdirectory that loops through a single category?
- How to add “Read More…” link in twentytwenty
- Override template file i subfolders
- Single Page theme [closed]
- How to display only posts assigned to a particular, isolated, subcategory
- Highlight wp_nav_menu when category is selected
- Archive.php filtered by pre-determined category
- The default code for “posts_nav_link” on category.php isn’t working
- Only one post is showing on category page, why?
- Why category.php throw 404 in wordpress while calling paginate_links()?
- WP didn’t redirect to canonical category URL
- Categories overview that links to page displaying posts
- Custom Walker for wp_list_categories
- Does “show_option_all” in wp_list_categories do anything?
- Is the “_s” on this `sprintf(__(‘Page %s’, ‘_s’), max($paged, $page))` just refer to a text domain?
- How to use get_template part in the plugin?
- How to insert category list into post creation page, and retrieve chosen categories?
- How to do some action weekly?
- Template for landing pages
- Question on using custom structures for categories
- Why still output /wp-content/themes/twentynineteen?
- So my theme doesn’t have a category.php file
- What Must to Display the “mysite.com/category” URL?
- How do I retrieve the category ID (ugly permalinks) in my sub-navigation menu?
- Using if statement in index.php instead of creating separate template files
- Create theme for mobile phones and tablets only?
- Theme for subcategories
- Template for product-category page [closed]
- Display subcategories selectbox on each category page
- Show post categories
- Add description to categories menu in admin
- filter a loop base on specific category
- Problem with multiple loops in wordpress theme
- Displaying year once in category.php [duplicate]
- How can I include custom category and tag base in template files?
- How to detect /category and /tag base pages?
- Include home page template in specific category template
- List categories of a post hierarchically?
- Showing different posts on category pages
- Displaying categories in different template problem
- In if…else condition, the else statement shows even if if statement is correct
- Regarding Tags And Categories
- Custom Archive Template for Multiple Categories
- How to show some of category in wordpress
- Category custom template is not showing correct posts
- Media Library Categories
- How can I add HTML classes for current taxonomy/term hierarchy into my pages to simplify styles?
- Change single.php template based on parent category
- the_content() not showing full posts in category template
- Most efficient way to have 1 template for parent, 1 template for child categories?
- Include category name in page template
- Category Templates for Post Types not Working
- Having some trouble properly displaying Custom Post Types in templates
- One category not displaying template updates
- Category base 404 – fix
- Category page with gallery for each post
- How do I get a single page navigation depending on the previous page?
- Add 1 category more to If_in_category statement
- Duplicate homepage to show posts from 1 category
- Category Template – to be editable from the backend?
- How can i hide the authors box from a specific set of categories and post types?
- have_posts is empty on category.php
- How to create a template for categories
- How to display the category featured images [closed]
- Meaning of “if ( is_home() && ! is_front_page() )” snippet?
- How to make /category/ URL load properly instead of 404 error?