Created
March 8, 2023 10:48
-
-
Save Digiover/c06b70999120c8bf4f01f5acabae117e to your computer and use it in GitHub Desktop.
Clean up WordPress meta data, like comment and post meta. Don't forget to set your table prefix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Clean WordPress Post Meta Data | |
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; | |
-- Clean WordPress Comment Meta Data | |
SELECT * FROM wp_commentmeta WHERE comment_id NOT IN ( SELECT comment_id FROM wp_comments ); | |
DELETE FROM wp_commentmeta WHERE comment_id NOT IN ( SELECT comment_id FROM wp_comments ); | |
SELECT * FROM wp_commentmeta WHERE meta_key LIKE '%akismet%'; | |
DELETE FROM wp_commentmeta WHERE meta_key LIKE '%akismet%'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment