WordPress.org

Ready to get started?Download WordPress

Forums

prevent post slug from adding -2,-3,etc... on same title (7 posts)

  1. gbaka
    Member
    Posted 4 years ago #

    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?

  2. stvwlf
    Member
    Posted 4 years ago #

    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.

  3. gbaka
    Member
    Posted 4 years ago #

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

  4. lee.jordan
    Member
    Posted 4 years ago #

    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.

  5. stvwlf
    Member
    Posted 4 years ago #

    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.

  6. lee.jordan
    Member
    Posted 4 years ago #

    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.

  7. stvwlf
    Member
    Posted 4 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic