Skip to content

Instantly share code, notes, and snippets.

@sabrina-zeidan
Created July 22, 2017 15:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sabrina-zeidan/e96ccd8a01da7ad05f8b3059ce85799a to your computer and use it in GitHub Desktop.
Save sabrina-zeidan/e96ccd8a01da7ad05f8b3059ce85799a to your computer and use it in GitHub Desktop.
Bulk delete all terms of given taxonomy [Wordpress]
function delete_all_terms(){
$taxonomy_name = 'city';
$terms = get_terms( array(
'taxonomy' => $taxonomy_name,
'hide_empty' => false
) );
foreach ( $terms as $term ) {
wp_delete_term($term->term_id, $taxonomy_name);
}
}
add_action( 'wp_head', 'delete_all_terms' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment