$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>Custom Archive Template for Multiple Categories|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Custom Archive Template for Multiple Categories

matteradmin8PV0评论

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?

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far