“Reversable” and “Re-useable” Subcategories (or other taxonomic structure)

Hope you can help a WP newbie 🙂

It is my understanding (and please correct me if I’m wrong!) that I cannot use the same subcategory slug in multiple parent categories, i.e. this structure is impossible with WP’s category functionality:

Read More
   example.com/design/exotic/my-post/
   example.com/travel/exotic/another-post/

My question is a two-parter:

  1. Are there any plugins or code I can use to coax WP into structuring URLs this way?

  2. Is there a way to tweak the category archive page template to generate example.com/exotic/, which would include posts from /design/exotic/ and /travel/exotic

If this is way more trouble than it is worth, please let me know. If so, I’m willing to sacrifice the subcategory in the URL structure. #2 is the most important to me: being able to have a mysite.com/exotic/ page that draws from multiple categories.

Thanks!

Related posts

Leave a Reply

1 comment

  1. The only possible way I can think to achieve this would be through getting neck deep in rewrite rules. You would have to flip your actual category structure around so that ‘exotic’ is the parent category, with two subcategories, ‘design’ and ‘travel’. Obviously you would put any posts you wanted in /design/exotic, into /exotic/design, same for travel. So the effect is the same – the trick is getting WordPress to map permalink structure you want to the right query vars passed to index.php (not your themes index.php, core’s index.php).

    You could then add your own custom rewrite rules that would capture the patterns of '(.+?)/exotic/?$' = 'index.php?category_name=$matches[1]'. Setting up that rule would look at any category page with /{category}/exotic pattern and take the part before the /exotic as the category_name.

    Please please please keep in mind I wrote that regex pattern mostly off the top of my head (and a quick peak at a rewrite rule I wrote for something completely different – so its not tested by any means.