Created
October 31, 2012 10:26
-
-
Save fulippo/3986307 to your computer and use it in GitHub Desktop.
Query to remove orphaned taxonomy terms from a WordPress DB
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
-- Replace %s with table prefix | |
DELETE tr | |
FROM %s_term_relationships tr | |
INNER JOIN %s_term_taxonomy tt | |
ON (tr.term_taxonomy_id = tt.term_taxonomy_id) | |
WHERE tt.taxonomy != 'link_category' | |
AND tr.object_id NOT IN (SELECT ID FROM %s_posts); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment