Created
July 22, 2017 15:13
-
-
Save sabrina-zeidan/e96ccd8a01da7ad05f8b3059ce85799a to your computer and use it in GitHub Desktop.
Bulk delete all terms of given taxonomy [Wordpress]
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
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