Basically, Latest version of WordPress has 2 categories by default
1. Tags
2. categories.
Categories and tags are ways to organize and find posts within a blog and across blogs. Categories are like topics whereas tags are more like keywords.
Few days back my friend asked me, How can I delete terms from WordPress.yes, You can delete manually from WordPress admin panel but when you have a lot of terms in hundreds or thousands of value then it takes a lot of time.
As a developer, manually delete which is not the good way so you need to apply query which can delete the terms from the database.
So I have written one script to delete terms/taxonomies from database, just a few minutes and your all taxonomies removed from database like Magic 🙂
You need to create one custom file and put it into WordPress root folder. place below codes into it.
Here is the code for that.Let’s dive into it.
NOTE:Make Sure You Have the backup of the entire database so that you can get back to a known state if things go wrong.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | //include file require_once($_SERVER['DOCUMENT_ROOT']."/wp-load.php"); //Query Code $results= $wpdb->get_results("select * from {$wpdb->prefix}term_taxonomy where taxonomy LIKE 'post_tag'", ARRAY_A ); foreach ($results as $row){ $wpdb->query("delete from {$wpdb->prefix}terms where term_id = '".$row['term_id']."'") ; $wpdb->query("delete from {$wpdb->prefix}term_relationships where term_taxonomy_id = '".$row['term_taxonomy_id']."'"); } $wpdb->query("delete from {$wpdb->prefix}term_taxonomy where taxonomy LIKE 'post_tag'"); //if translation plugin installed into wordpress,apply below query $wpdb->query("delete from {$wpdb->prefix}icl_translations where element_type LIKE 'tax_post_tag'"); |
Copy above code and place it.That’s it you’re done,I have tested it with latest version of wordpress 3.5.1 too.
Thank you for reading.Feel free to share your thoughts! Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.