Created
November 19, 2022 04:32
-
-
Save steamboatid/166c658f05d06fd95b0bfba741805e56 to your computer and use it in GitHub Desktop.
delete all wordpress terms
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 a, b, c | |
FROM `wp_term_relationships` AS a | |
INNER JOIN `wp_term_taxonomy` AS b ON (a.`term_taxonomy_id` = b.`term_taxonomy_id`) | |
INNER JOIN `wp_terms` AS c ON (b.`term_id` = c.`term_id`) | |
WHERE a.`object_id` IN (SELECT `ID` FROM `wp_posts` WHERE `post_type`='post'); | |
DELETE a, b, c | |
FROM `wp_term_relationships` AS a | |
INNER JOIN `wp_term_taxonomy` AS b ON (a.`term_taxonomy_id` = b.`term_taxonomy_id`) | |
INNER JOIN `wp_terms` AS c ON (b.`term_id` = c.`term_id`) | |
WHERE a.`object_id` NOT IN (SELECT `ID` FROM `wp_posts`); | |
DELETE | |
FROM `wp_terms` | |
WHERE `term_id` IN | |
(SELECT `term_id` FROM `wp_term_taxonomy` WHERE `count` = 0); | |
DELETE | |
FROM `wp_terms` | |
WHERE `term_id` NOT IN | |
(SELECT `term_id` FROM `wp_term_taxonomy`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment