Created
April 9, 2014 16:15
-
-
Save Kevinlearynet/10287914 to your computer and use it in GitHub Desktop.
MySQL query to delete 'wp_posts' rows and 'wp_postmeta' rows from a WordPress database
This file contains 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
# Delete all posts with given post type | |
DELETE FROM wp_posts WHERE post_type = 'shop_order'; | |
# Delete all orphaned post_meta | |
DELETE wp_postmeta FROM wp_postmeta | |
WHERE NOT EXISTS ( | |
SELECT * FROM wp_posts | |
WHERE wp_postmeta.post_id = wp_posts.ID | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment