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
- 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 do I get the trackback count of a post in wordpress without writing an SQL query?
- How to do some action weekly?
- Limit number of posts on a custom category template – breaking pagination
- Template for landing pages
- Question on using custom structures for categories
- How to add menù section to my WordPress template?
- How can I display the number of post associated to a category in Twig/Timber WordPress? [closed]
- Getting the category title / description returns first matching post?
- Is it possible to have a template that works on multiple categories where the link address contains the specific category?
- Why still output /wp-content/themes/twentynineteen?
- So my theme doesn’t have a category.php file
- Custom template for sub-sub-categories
- Allow user to select categories that will display in post loop
- Insert HTML content in WP Query at specific point
- What Must to Display the “mysite.com/category” URL?
- How do I retrieve the category ID (ugly permalinks) in my sub-navigation menu?
- Give posts a particular template based on the assigned category
- Category page returns 404 error
- How to use wp_list_categories with plugin category?
- Using if statement in index.php instead of creating separate template files
- Create theme for mobile phones and tablets only?
- Why is my sub-category template showing the wrong posts
- Theme for subcategories
- Template for product-category page [closed]
- Add Date & Author Meta to Category Archive Page
- Display subcategories selectbox on each category page
- Theme modification for custom category menus
- 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]
- Category link redirect to custom template page instead of index.php?
- I would like to feature a tip on the homepage
- How to add icon over specific thumb
- How can I include custom category and tag base in template files?
- Different header for each category
- How to detect /category and /tag base pages?
- Category Template – Show Last Entry as Featured
- Custom post type archive category page results in 404
- Include home page template in specific category template
- List categories of a post hierarchically?
- Output Title of Post’s Current Category
- Showing different posts on category pages
- Displaying categories in different template problem
- WooCommerce shared categories
- Include last post date in get_categories loop
- Show the number of the post
- How can i add service category here? [duplicate]
- How do I remove “Uncategorized” from my theme on my posts page?
- Products category search not working
- In if…else condition, the else statement shows even if if statement is correct
- Can’t display posts by filtering categories using isotope.js
- Category page 404s on mobile but not desktop?
- 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
- Style a category page the same way as the homepage?
- Adding a category view to a page
- Using a template page parent breaks page
- 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
- Jetpack Mobile Theme: when on smartphone on categories the theme suddenly changes to jetpack mobile theme even though it’s deactivated
- Use different file includes for single.php
- Display Taxonomies in loop with template args
- Getting page/category content to show up in my custom page template
- If it is a top level category show children otherwise show sibling categories
- Lowest catagory link
- Removing categories, Comments etc from posts?
- 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
- How to get multiple loop in category.php, my scripts becomes madness
- One category not displaying template updates
- Category base 404 – fix
- Category page with gallery for each post
- Custom built theme won’t filter categories
- WordPress a template for subcategories fo a given category, but not for root category
- 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 Archives: Show posts categorized in parent category only