• Anonymous User 319290

    (@anonymized-319290)


    I am using

    /category/date/slug

    as my site’s permalink structure. For a variety of reasons, I will be using the same slugs repeatedly for different posts. For example:

    /weather/2008/01/20/chicago
    /weather/2009/05/05/chicago

    WordPress won’t allow the most recent slug as unique url. Instead, it adds a number to the slug:

    /weather/2008/01/20/chicago-2

    This behavior is undesirable. Is there a plugin or other way to get wordpress to incorporate the date so that the urls are considered unique?

Viewing 5 replies - 1 through 5 (of 5 total)
  • as far as I know, No the slug must be unique, not just the unique combination of the slug and the date. The possibility exists of you having two posts on one day with “chicago” as the slug. Also, what if in the future you decided to change your permalinks to /%postname%/ ?

    it used to be the case that this plugin fixed that behavior

    https://www.ads-software.com/extend/plugins/singular/

    now it doesn’t seem to work

    Any word on this? A plugin, or a fix to go in and edit the function that creates the slug-2, slug-3 instances?

    The urls of my site are never going to change (ie, no 2 similarly-named posts will ever be in the same category, etc), so I would prefer to be able to use the same slug for multiple posts.

    Thanks

    ugh, I implemented an extremely roundabout hack to take care of this issue:

    In wp-admin/posts.php, a check to see if the slug is being appended by the -2, -3 numerals.

    If it is, truncate it before the appendage, then store it as usual.

    But of course these posts don’t play nice in the loop after this. To get around this, I had to include a custom query in my single.php. I get the post as normal (by slug) — but of course now there are multiple posts with the same slug, so it’s screwy.

    In order to make sure I get the post I want, I grab the url, and identify the lowest child category from the permalink (what the template should be displaying). Then I get the lowest child category of the posts in question (there shouldn’t be more than one similarly-named post in any given subcategory) and compare each’s category ID to that of the one from the URL.

    If they match, that means it’s the post that’s intended to be there.

    …extremely ugly, but it seems to work!

    Hi. I’m fairly new to WordPress and, after working a couple static pages, and sub-pages, my slugs now have a “-3” at the end. I’d very much like to get rid of these.

    I have tried editing the slug but the url does not change. I have deleted all the old versions of the pages so there shouldn’t be any conflict. I also tried some plugins that were referenced in similar threads but no matter what I do the slug (and url) revert to “-3” version.

    Is there any way to fix this?

    I took a peek into the posts.php table and noticed that there are lines for each of my older versions of the page — would it be possible to change it there?

    Thanks for your help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘unique permalinks and reusing slugs’ is closed to new replies.