I recently had a web site redesigned and migrated to another domain. The new site uses WordPress as a CMS for the whole site (it just managed the blog on the previous one). Somehow in the process of setting up the new site, the designer added a whole slew of categories, 953 of them to be exact, and most of them have zero posts attached and will never be used.
I want to clear these zero-categories out, but it would take forever using the WP interface to do this, which only shows 20 at a time. Is there some way to do it with a MySQL operation? I’m reluctant to just delete them from the categories table because I don’t know how they are linked elsewhere in the DB. OTOH maybe if the category has zero posts it doesn’t matter?
I know there is some WP method to safely do this because the categories page on the dashboard has to call it when you delete a category, but I can’t figure out what it is from looking at the form.
What worked for me is:
Caution 1: Previously backing up your database might be a good idea.
Caution 2: This also deletes empty parent categories of non-empty child categories. If you have such cases you will have to update the
parent
column inwp_term_taxonomy
table afterwards.If you click the ‘screen options’ button at the top of the control panel you can choose how many categories to display in the WP interface, then do the bulk-delete using the checkboxes.