404 Tech Support

How to merge and manage categories and tags in WordPress easily

Yesterday, I started doing some long delayed clean up of categories here on 404 Tech Support. I felt like the categories had become too sprawling and too specific. Things could be improved by consolidating similar categories into one. Renaming the categories was the easy part. As I looked at the categories I wanted to merge, there were hundreds of posts in some of the old categories that would need to be updated to align with the end goal.

I dove into phpMyAdmin to run a few SQL queries to update the posts in the term_relationships tables. Unfortunately, as I thought that through, it wasn’t such an easy query. If categories were a 1-to-1 relationship, things would be easier. Unfortunately, categories and posts are many-to-many. If I wanted to get rid of category B, I would update all posts that were in category B to instead be in category A but what if there was a post that was already in category A? The situation was growing more complex, the more I thought about how to address my taxonomy mess in the wp_term_relationships table. Fortunately, a quick search of the WordPress plugins found just the tool to do the job: Term Management Tools.

Term Management Tools is a simple WordPress plugin. You install and activate the plugin and that’s it. There is no configuration page to change settings, it just extends the functionality of your taxonomy tools for categories and tags.

On the Categories page, when you check the box in front of one or more categories or tags, you get additional options under the Bulk Actions drop-down. With the plugin enabled, you can easily set a parent for your hierarchy, change the taxonomy, or merge multiple terms into another one. I checked the boxes in front of the category I wanted to merge and typed the name of the category I wanted those posts to join and hit the Apply button.

Upon completion, the posts in the first category were now part of the larger category and the old category was deleted. In other words, it worked exactly how I expected it should and far more easily than trying to get the queries correct myself. While my focus was on categories, it works similarly for tags. In my opinion, this functionality should be adopted into the WordPress core.