How best to fix accidentally deleted post slugs
-
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?
Thanks!
HB.
- The topic ‘How best to fix accidentally deleted post slugs’ is closed to new replies.