Where Did My Categories Go?


Organizing Your BlogTo tag heaven. Ah, yes… tags. The teacher’s pet of Web 2.0. The category list on this blog had become rather unwieldy as I just plugged in new categories whenever I did not feel like putting any thought into organization. I never really liked that method and so when WordPress implemented tags I figured I’d make the move. The only problem was converting all of my old categories into tags. This was quite an undertaking and it actually took some MySQL DB tweaking… muahahaha!

Converting Categories To Tags

Fear not, though! There is a Category to Tag converter in the WordPress admin under Imports. This came in quite handy. However, if you did like me and waited too long you may have some terms that are both a category and a term. For instance I used Apple as a category for a while and then started tagging posts with Apple instead. The Category To Tag converter will not convert your category in this instance… bummer. If you need to solve this problem go back and remove all of the Apple tags from posts and mark them with the equivalent category. Once that tag is completely gone from all posts you can delete the tag in your system. How do you do that?

Well, using phpMyAdmin or another similar SQL tool for accessing your MySQL database issue the following query:

SELECT * FROM `wp_terms` WHERE `name` = 'Apple'

This will get the `term_id` for you which you will need in the next query. So write down the `term_id` and move to the next step:

SELECT * FROM `wp_term_taxonomy` WHERE `term_id` = 'TERM_ID from previous step'

OK, if you truly do have both a category and a tag in your system there should be two entries showing. One will have a taxonomy = ‘post_tag’ and the other will have a taxonomy = ‘category’. In phpMyAdmin you can just click the red X next to the ‘post_tag’ row and DELETE it. Otherwise you can issue a query like this:

DELETE FROM `wp_term_taxonomy` WHERE `term_id` = 'TERM_ID from previous step' AND `taxonomy` = 'post_tag'

Now that the tag is completely gone the converter should allow you to convert this category to a tag… and then your laughing (as the British say).