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 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 Jan 18 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 Jan 18 at 17:08
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?

  • That's perfect! Thank you so much! A very straightforward solution. – Ben Jan 18 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.