do child categories inherit template of parent category?
-
I’ve been searching endlessly for an answer to this in the codex and forums and everywhere else I could think of on third-party sites catering to WP. I’ve been so frustrated that I almost gave up and went with another platform several times. I guess I should have asked here sooner, but I didn’t want to look silly for asking something so obvious.
If I have three main categories, all with their own sub-category hierarchies, and I want to have a distinct custom category template for each of the three categories AND their descendent categories, what do I do?
I thought about trying something like this:
if(is_category(2) || in_category(2):
// print layout of category 2
endif;
I could also just make a separate category template for each of the three main sections:
category-2.php
category-3.php
category-4.php
But making separate category templates wouldn’t accomplish what I need UNLESS all of the categories nested underneath category-2 would also inherit the template for category-2.
Do I have to explicitly declare every single sub-category of category-2 (which could be many, many categories and a whole lof of maintenance work)?
if(is_category(2) || is_category(15) || is_category(56)):
// and so on, and so on....
endif;
I prefer to not install plugins if this can be done with the functions already available to me in WP.
EDIT: The reason I need this is because I want to avoid having to install multiple copies of WP (or WPMU, for that matter) on my server to accommodate the different page types (i.e. text-based section, image-based section, another section, etc.). I want one all-inclusive website that can share posts between these sections – the only difference between them is how they’re displayed on archive pages and which fields are printed to the page.
- The topic ‘do child categories inherit template of parent category?’ is closed to new replies.