Last active
June 1, 2018 20:30
-
-
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.
This file contains hidden or 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
////////////////////////////////// | |
// 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