Cleans up metadata from metadata table from posts that have been deleted:
SELECT * FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL;
DELETE pm FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL;
credit: https://www.inmotionhosting.com/support/edu/wordpress/cleaning-up-old-post-meta-data-in-wordpress/
Delete duplicate posts:
DELETE bad_rows.* from wp_posts as bad_rows inner join ( select post_title, MIN(id) as min_id from wp_posts group by post_title having count(*) > 1 ) as good_rows on good_rows.post_title = bad_rows.post_title and good_rows.min_id <> bad_rows.id credit: https://cleverplugins.com/delete-duplicate-posts-wordpress/
0 Comments