F
F
Ferzet2016-04-07 16:10:48
WordPress
Ferzet, 2016-04-07 16:10:48

How to make your own category.php for child categories?

There is a category "Recipes" on the wordpress site of the culinary theme, a custom template has been made for it via category-slug.php (category-recepty.php). In the "Recipes" category, there are many child categories (recipes for salads, biscuits, soups, meats, etc.). How to make a custom template for displaying recipes in child categories? Make a template for each child category? Then there will be too many of them, and it seems to me that this is not entirely correct. Maybe there is some other way?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Kozlov, 2016-04-08
@Ferzet

There are at least 2 solutions:
1 - create a category.php or archive.php template, all categories will be displayed through them (for example: if there are news or articles, they will also be displayed through this template). You can use the is_category( 'Stinky Cheeses' ) validation function to return different html for different categories.
Option 2 is the most beautiful. You need to create a recepties taxonomy (you can google: wordpress taxonomy for categories). Create template taxonomy-recepties.php. This template will work for categories and subcategories of the created taxonomy.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question