What’s the best way to make WordPress accept non-unique sub-category slugs?
-
Hey everyone, I have a WordPress site architecture problem that keeps coming up. Any help would be appreciated…
By default, WordPress ensures that every ‘slug’ portion of permalink URLs is unique, and is very savvy about using this to ensure you never see a 404 from omitting a portion of the URL. This means if my permalink structure is…
https://site-root.com/category-name/sub-category-name/post-name/post-id
Then….
https://site-root.com/category-name/sub-category-name/post-name/post-id,
https://site-root.com/category-name/sub-category-name/post-name,
https://site-root.com/category-name/sub-category-name/post-id, and
https://site-root.com/sub-category-name/post-name/post-id
will all take me to the same post.But if that kind of fail-safe redirection is less important to someone than being able to have non-unique slugs (and nicely structured directories), I’m SOL.
Let’s say I’m writing a restaurant review guide in major cities. I want my top-level categories to be city names, and the types of restaurants to be the sub-categories. So I create “Boston”, “New York”, and “Seattle”, then I add the sub-categories “Chinese Food”, “Italian Eateries”, and “Luxury Dining” to Boston. But when I try to add the same sub-categories to New York, even when I specify the URL slugs, WordPress starts forcing slugs like “https://[site-root].com/New-York/Chinese-Food-New-York/” — unnecessary repetition, and lengthening my links. This gets even worse if I want to have sub-sub-categories.
Any ideas for a solution?
- The topic ‘What’s the best way to make WordPress accept non-unique sub-category slugs?’ is closed to new replies.