WordPress.org

Support

Support » Themes and Templates » prevent post slug from adding -2,-3,etc… on same title

prevent post slug from adding -2,-3,etc… on same title

  • how would i prevent the post slug from adding the -2,-3,etc… on same post names the names and post are obviously different as they include the category. Is there a plugin that does this or how would i do this?

Viewing 6 replies - 1 through 6 (of 6 total)
  • You can’t prevent it. it doesn’t matter that the category is part of your permalink. WordPress requires a unique post slug for each post. If a post slug already exists that has the name you want on the current post slug, as you see it adds a suffix to the slug it comes up with.

    What you can do is change the slug that WordPress comes up with and make it something unique that YOU decide rather than taking WP’s default choice.

    I’m pretty sure you can do it I’ve seen it done I just don’t know how to…

    There does seem to be a bad flaw with how the permalink structure works, I assume it’s just looking at the post slug and matching that and not even reading that its in a category. If the permalink took account of its context rather than just matching on the last string in the URL, we wouldn’t need to nave unique slugs.

    category1/story-slug and
    category2/story-slug

    should bring back the same post because a post should be able to co-exist in multiple categories, and that’s the reason for needing a unique post slug. Be nice if it was more context aware though.

    should bring back the same post because a post should be able to co-exist in multiple categories, and that’s the reason for needing a unique post slug. Be nice if it was more context aware though.

    The problem with that is a post can be added to or removed from any category at any time, which leaves the potential for multiple posts with the same URL.

    Yes I can see that aspect of it, but that’s not really what I’m saying. I’m actually backing up the theory that two different posts cannot and should not have the same slug or permalink, my example is highlighting one post slug and the slight lack of context of category structures sometimes.

    And if they were two stories in different categories with the same name, when moving the posts in and out of categories there could be a way of automatically rechecking the slug to make it unique again.

    And if they were two stories in different categories with the same name, when moving the posts in and out of categories there could be a way of automatically rechecking the slug to make it unique again.

    which would break all existing links to the page, including Google’s

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘prevent post slug from adding -2,-3,etc… on same title’ is closed to new replies.