[resolved] Regenerate all slugs from post title? (7 posts)

  1. gunnerstown
    Posted 1 year ago #

    I just migrated from Squarespace to WordPress and all of my post slugs (>1500 of them) are incorrect. They have a 7-digit number (date) added to the front of them:

    this-is-the-desired-slug has become 2013524this-is-the-desired-slug

    I have searched high and low for the easiest way to correct this. I was hoping that there would be a plugin that would regenerate all slugs using the Post Title, but can't seem to find one! :(

    I'd like to retain the old site structure so that when I point my domain from the old host to the new one, all the links work.

    Any suggestions? Thanks.

  2. keesiemeijer
    Posted 1 year ago #

  3. gunnerstown
    Posted 1 year ago #

    Thanks for your reply. I saw that suggestion already, but from the looks of it, it will sanitize the slug, which I don't want to do, since it will strip the "the" and "a" etc. from the slug...

    Any other suggestions?

  4. keesiemeijer
    Posted 1 year ago #


    Despite the name of this function, the returned value is intended to be suitable for use in a URL, not as a human-readable title. It will not strip words or letters from the title. It does replace special accented characters.

    if I do this:

    <?php echo sanitize_title('will it strip the and a from a slug'); ?>

    It prints:

  5. gunnerstown
    Posted 1 year ago #

    OK... Thanks.

    Now a really stupid newbie question - how exactly do I run that function? :-P

    I know it has something to do with function.php...


  6. gunnerstown
    Posted 1 year ago #

    And is there anything i would have to change in that code you sent me? Or will it automatically go through every post and replace the slug with the post title?

    Just checking that there isn't anything custom in the code.

    Appreciate your help very much! :)

  7. gunnerstown
    Posted 1 year ago #

    Thanks keesiemeijer - it seems to have worked. You've saved me hours of work! :)

Topic Closed

This topic has been closed to new replies.

About this Topic