Powerful websites, with style.

Different Templates For Parent And Child Category Archives

This tutorial shows you how to use a different template via get_template_part() for parent and child terms of a post. You could make this work for custom post types or custom taxonomies too, but in my case it was just regular posts and categories.

The site has a category called “Recipes”, and a bunch of child categories like “Beef”, “Poultry”, “Breakfast”, etc…

The recipe index needed one template, while all child terms needed to share another template.

Conditionally pull in a template

Inside my category.php file I pulled a different template based on the term. See the code below.

Then, in my child theme I included 2 files in the /includes/ directory.

recipe-parent.php

recipe-child.php

From there you can do whatever you’d like. The contents of my parent file is some static HTML just showing links to each child category. The child categories show recipes in 3 columns with just the title and featured image.