Is there a way to have duplicate category slugs?

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.

Leave a Comment