SQL query to turn categories into tags (and vice versa)

February 11, 2013 at 5:23 pm

Using the “Categories to Tags” tool, WordPress allows you to easily turn categories into tags. But if you have lots of categories to convert, this will take a while. Here is a simple SQL query that will turn all your categories into tags in a second.

Just run the following query on your WordPress database, and all categories will be turned into tags. Don’t forget to replace the table prefix wp_ if your database is using another prefix.
And of course, do not forget to make a backup of your database before running the query!

UPDATE wp_term_taxonomy SET taxonomy='post_tag', parent=0 WHERE taxonomy='category';

Thanks to Go WordPress for the tip!