How to restore WordPress categories

After upgrading to the latest version of WordPress, vitamin the text of all of the categories were deleted. It appears this may be my fault for not disabling all of the plugins before doing the upgrade (oops). They’re back now though. It was somewhat annoying to have to do, here but as far as “data loss error”s go, ambulance it wasn’t very bad at all.

I noticed a bunch of other people online had similar problems but nobody mentioned a solution so I figured I might as well throw up a quick description of what I did.

I used google to find a cached version of my page which listed all of the categories in the side-bar. Now I had all of the categories but I didn’t know which id in the database matched which category. I found that out by running this query:
SELECT post_title, term_taxonomy_id FROM wp_posts,wp_term_relationships WHERE wp_term_relationships.object_id=wp_posts.ID ORDER BY term_taxonomy_id;
Which shows what posts were assigned to each category. After reading through the list and figuring it out, I was able to fix the text by typing queries along the lines of:
UPDATE wp_terms SET name='Motive Force', slug='motive-force' WHERE term_id=8;

Since I brushed over it above:
To find a cached version of your site on google, just search for “”, then click on “Cached” next to any of the results. They clear those out after a while, so don’t put it off!

2 thoughts on “How to restore WordPress categories

  1. I waited too long. Cached pages no longer show the list of categories. I think I remember a lot of them …

    Question is: When you say “running this query” where and how exactly do you do that?

  2. Peter,
    This information is in a MySQL database for your WordPress installation. To run a query, you need to figure out how to access MySQL… If you have a shared hosting account you can generally find something called “phpMyAdmin” which lets you run queries on the database.

    phpMyAdmin is by far the easiest way to access your MySQL database to start out with. If you don’t have phpMyAdmin or any other “query browser” program, you can try to get SSH access and connect to MySQL via the command-line. There’s a bit of a learning curve there usually.

    Let me know how it goes! (or if you have additional questions)

    – Sean

Leave a Reply

Your email address will not be published. Required fields are marked *