Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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:

   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!

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer
    
Awesome, thanks so much for the help. I think I might just use tags though and forget about subcategories :) –  rkarbowski May 14 '12 at 15:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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