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.

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.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
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
    
Thanks for the help! –  Jordan May 3 '13 at 16:36

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.