0

I'm creating a website and I'd like to be able to reuse the same slug/post name in the page's url.

ex using /%category%/%postname%

foo.com/bar/page
foo.com/barz/page // Will not work. Instead it will use page-2.

I've done some research and it doesn't look like it's possible to do what I want. Before I give up on trying to get the url structure to work like I would like, I figured I would reach out to the WordPress community to see if anything has changed in a newer release to allow this behavior. I'd really like to avoid using %post_id% at all costs because I don't think it looks very nice in the url.

2

This is not natively possible, since in your example permalink structure posts are detected by slug alone, and not combination with category. Essentially category info gets simply discarded.

If your requirements involve only one (few) of possible endings for URL you might achieve this relatively easy using endpoints, see add_rewrite_endpoint().

However in generic scenario slug collisions won't work.

2
  • Thanks for the fast reply. It's a shame that WP discards the slug & category combination. I assume adding %post_id% to the permalink won't change anything?
    – Jordan
    May 3 '13 at 16:31
  • Probably won't. The post slug is essentially main textual identification for a post (since GUIDs are a mess) and WP doesn't like it collide.
    – Rarst
    May 3 '13 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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