Skip to content

Instantly share code, notes, and snippets.

@wpsmith
Created February 15, 2014 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpsmith/9025752 to your computer and use it in GitHub Desktop.
Save wpsmith/9025752 to your computer and use it in GitHub Desktop.
SQL: Delete Unused Post Tags
DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE count = 0 );
DELETE FROM wp_term_taxonomy WHERE term_id not IN (SELECT term_id FROM wp_terms);
DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment