Skip to content

Instantly share code, notes, and snippets.

@landbryo
Last active June 1, 2018 20:30
Show Gist options
  • Save landbryo/a96962b9cc5151bb85b8e35d270387eb to your computer and use it in GitHub Desktop.
Save landbryo/a96962b9cc5151bb85b8e35d270387eb to your computer and use it in GitHub Desktop.
Use this function to quickly delete all taxonomy terms in chosen taxonomy. Replace tax-slug with your taxonomy's slug and load any page while logged in as an admin.
//////////////////////////////////
// DELETE ALL TERMS IN TAXONOMY //
//////////////////////////////////
function landbryo_delete_terms() {
if ( is_admin() ) {
$tax = 'tax-slug';
$terms = get_terms( $tax, array( 'fields' => 'ids', 'hide_empty' => false ) );
foreach ( $terms as $value ) {
wp_delete_term( $value, $tax );
}
}
}
add_action( 'init', 'landbryo_delete_terms' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment