I don’t think there is one right way to do this ... it depends on the scenario ... How many messages, how often sections or "main threads" are added / changed, you need other things on the pages, etc.
One fairly simple and easy to maintain solution:
1. Add mechanical , electrical , etc. as categories next to news , articles and events
2. Change (or add) category.php to repeat the loop three times and display only messages related to each section (another category):
//Loop your sections foreach(array('news', 'articles', 'events') as $category) { echo '<h2>' . $category . '</h2>'; //Loop posts while ( have_posts() ) { the_post(); //Check if post is in section (by slug!) if ( in_category($category) ) { the_title(); the_content(); } } //Start the loop over rewind_posts(); }
Now simply assign each message to one (or more) “parents”, fx mechanical , as well as one (and only one) of news , articles or events ...
- If you go to the
mechanical archive page, you will get three sections - if you go to
news you will get all the news (but also two empty sections, so of course you have to check it out).
Note that this can be done using tags or even a custom taxonomy, if you want, you just need to edit another theme file - see the hierarchy template.
Beware that this doesn’t work well with pagination, so if this is a concern, you will have to deal with it.
source share