Created
July 30, 2018 19:13
-
-
Save filmgirl/c833c7a4433d1112111bb1fc5ebda5b0 to your computer and use it in GitHub Desktop.
SQL query for efficiently deleting WordPress CPT
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 FROM wp_posts | |
WHERE post_type = 'post_type'; | |
DELETE FROM wp_postmeta | |
WHERE post_id NOT IN ( | |
SELECT | |
id FROM wp_posts); | |
DELETE FROM wp_term_relationships | |
WHERE object_id NOT IN ( | |
SELECT | |
id FROM wp_posts); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment