Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix How best to fix accidentally deleted post slugs

Discussion in 'Misc WordPress Requests' started by Hedley, Nov 29, 2017.

  1. Hedley


    How best to fix accidentally deleted post slugs, by Hedley

    My situation is that some, but not all, posts (possibly ~600-800) of a client site have somehow had the slug stripped out of the post_name field of the wp_posts table. Hence, the URL for these posts defaults to the site root (ie: “https://www.mydomain.com/”).

    I assume that this was the result of some admin user error, possibly when doing a DB search/replace. The question is, how to fix it. It appears that it’s been this way for a while, as the backups available to me also have this problem.

    I assume that the best way would be to use a phpmyadmin mysql query to build new slugs for the affected posts using the content of post_title as the source material (stripping spaces and punctuation), but I’m not a skilled mysql query writer. I can successfully search for the affected posts:

    SELECT *
    FROM wp_posts
    WHERE post_name = '' AND post_status = 'publish';

    But beyond that, I’m guessing. Obviously I need to do a crash course on sql queries, but in the short term, does anyone have any tips, links to similar problem/resolutions, or alternate resolution suggestions?



    How best to fix accidentally deleted post slugs

Share This Page

Monarch Social Sharing Plugin