Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Delete all tags of a WP install
<?php
/**
* Delete all tags of a WordPress blog
*
* @author Ashfame
*
* Place this file in root of your WordPress install and open it in the browser - domain.com/delete-all-tags.php
*/
echo '<h1>Delete all tags</h1>';
require 'wp-load.php';
echo '<h2>WordPress loaded</h2>';
$tags = get_tags( array( 'number' => '', 'hide_empty' => false ) );
if ( !empty( $tags ) ) {
echo '<ul>';
foreach ( $tags as $tag ) {
wp_delete_term( $tag->term_id, 'post_tag' );
echo "<li>Deleted \"{$tag->name}\" which had the ID {$tag->term_id} and had {$tag->count} posts in it.</li>";
}
echo '</ul>';
echo 'All done!';
} else {
echo '<p>Nothing to delete!</p>';
}
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.