Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Bulk delete unused tags [Wordpress]
function delete_empty_tags(){
$tags = get_tags( array('number' => 0,'hide_empty' => false));
foreach ( $tags as $tag ) {
$tag_count = $tag->count;
if ($tag_count < 1 ){
wp_delete_term( $tag->term_id, 'post_tag' );
add_action( 'wp_head', 'delete_empty_tags' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.