Skip to content

Instantly share code, notes, and snippets.

@ashfame
Created November 25, 2011 10:11
Show Gist options
  • Save ashfame/1393195 to your computer and use it in GitHub Desktop.
Save ashfame/1393195 to your computer and use it in GitHub Desktop.
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