Custom Archive Template for Multiple Categories

admin2025-06-04  0

I want to create a custom archive template for two post categories.

One of my categories is events, and the other one is courses (I have more). I already have a custom template for events (category-event.php), but I want to create another one to list both events and courses, but not include any other categories. The layout will be more or less the same as the category-event.php template. How can I do this?

I want to create a custom archive template for two post categories.

One of my categories is events, and the other one is courses (I have more). I already have a custom template for events (category-event.php), but I want to create another one to list both events and courses, but not include any other categories. The layout will be more or less the same as the category-event.php template. How can I do this?

Share Improve this question asked Jan 18, 2019 at 15:24 BenBen 1071 silver badge7 bronze badges 2
  • I don't understand your question. Are you looking to have 1 template for events and 1 for events AND courses and a third for everything else, or 1 for events and courses and one for everything else? – rudtek Commented Jan 18, 2019 at 16:38
  • Yes, I want to have one template for events and another for events AND courses, and a third for everything else. I have one already for events only (category-events.php) and for everything else (archive.php), but want to create one for events AND courses. Sorry if it wasn't clear. – Ben Commented Jan 18, 2019 at 17:08
Add a comment  | 

1 Answer 1

Reset to default 0

The simplest way I can think of would be to have the two categories you want to display together grouped under a parent category.

Parent Category
|----Child Category A
|----Child Category B

The file category-parent-category.php would by default show posts from both. The file category-child-category-a.php would only show from a. The file category-child-category-b.php would only show from b. The file category.php would show from all categories.

Would that do what you want?

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748996810a315478.html

最新回复(0)