Tag Archives: template hierarchy
WordPress categories follow a predefined template hierarchy. In most cases, we use “category-$slug.php” to override the template for an individual category to give it a entirely different look and functionality (“category-projects.php” for a “Project” category). If you have subcategories (Design, Development etc) of “Project” they also follow the WordPress template hierarchy and you have to create “category-design.php” and “category-development.php” to give them the similar look as of Projects category. This snippet allow you to configure some or all child categories to use their parent’s category template. In the scenario we just mentioned above, Design and Development categories will also land at “category-projects.php” instead of their own “category-$slug.php” template.