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.

Wordpress sometimes is plain limiting, and some of its logics I just don't get...

For example if I have two parent directories:

  • parent1
  • parent2

with subcategories:

  • parent1
    • sub
  • parent2
    • sub

I cannot have sub sub as slug or name... WordPress automatically appends what it thinks is best like sub-1 or sub-parent2. This is not very beautiful. And I consider this nothing short of a bug.

share|improve this question

2 Answers 2

Short answer: No - it can't be done.

Long answer: Category slugs must be unique, regardless of parent. Although quite a few people like to call this a bug, it's actually by design. Basically, since categories can be moved around at will, the slugs must be unique. Sure, it's nested properly now, but if you decide at some point to do away with your hierarchy and move to a flat category structure, you'll have duplicate URLs (instead of cat1/slug, cat2/slug you'll have /slug and /slug). To avoid people unintentionally breaking their sites, they've enforced this restriction.

If you do hack the database to force duplicate slugs, it won't matter - if you navigate to a page that has a duplicate slug, it will load the first instance of that slug in the database no matter what. So if your first 'sub' is category ID 5 and your second 'sub' is category ID 20, and you force them to have the same slug, any time you go to category 20, it will load category 5.

The only time I've seen this successfully overridden is with WPML (so subdomain languages can have the same slug - en/slug, fr/slug, de/slug, etc), and they took MONTHS to make it work - even then it still has issues.

share|improve this answer

Actually there is a plugin "Duplicate Category Paths" for duplicate category slugs which works for any taxonomy including categories, WooCommerce categories, etc., for example.

Cars
-Ford
--Parts
-Toyota
--Parts

Normally the permalink would be /cars/ford/ford-parts & /cars/toyota/toyata-parts, the plugin changes this to /cars/ford/parts & cars/toyota/parts respectively.

share|improve this answer
2  
There is a plugin … where? –  toscho May 10 '13 at 17:06
2  
You should probably mention that it is your plugin (or appears to be) and that it costs money. –  s_ha_dum May 10 '13 at 17:54
    
Ah, time for a standard snippet: You must disclose your affiliation in your answers. –  toscho May 10 '13 at 20:02

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.