Skip to content

Instantly share code, notes, and snippets.

@felipeelia
Created September 25, 2017 18:40
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 felipeelia/31461c515f9be24a34d7af9f3186f1b9 to your computer and use it in GitHub Desktop.
Save felipeelia/31461c515f9be24a34d7af9f3186f1b9 to your computer and use it in GitHub Desktop.
Delete ALL Terms In A Taxonomy (Use With Caution)
<?php
global $wpdb;
$taxonomy_slug = 'area';
$wpdb->query( "DELETE a, b, c, d
FROM {$wpdb->term_taxonomy} a
LEFT JOIN {$wpdb->terms} b
ON (a.term_id = b.term_id)
LEFT JOIN {$wpdb->term_relationships} c
ON (a.term_taxonomy_id = c.term_taxonomy_id)
LEFT JOIN {$wpdb->termmeta} d
ON (a.term_id = d.term_id)
WHERE a.taxonomy = {$taxonomy_slug}" );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment