WordPress upgrade to 2.6 deletes all Categories

After not having updated WordPress for a while (we were still on 2.3), the new WordPress iPhone Application convinced us that it was about time.

Unfortunately, all my categories were missing after the upgrade. Seems like the wp_categories table got removed an replaced by wp_terms and wp_term_taxonomy. The entries are still there, just without name and descriptions.

Fortunately there are ways to fix it (if you have a backup, harhar).

David Cumps wrote a nice post about how to fix it manually, but if you have lots of Categories, you can do it automatically too (if you prepare of it).

First step (before the upgrade) is to save a version of the wp_categories table:

mysqldump -uUsername -pPassword wordpress_db
wp_categories > wp_categories.sql

After the upgrade you have to play it back and run the following two queries:

mysql -uUsername -pPassword
wordpress_db < wp_categories.sql

UPDATE wp_terms, wp_categories
SET wp_terms.name = wp_categories.cat_name,
wp_terms.slug = wp_categories.category_nicename
WHERE wp_terms.term_id = wp_categories.cat_ID

UPDATE wp_term_taxonomy, wp_categories
SET wp_term_taxonomy.description =
wp_categories.category_description
WHERE wp_term_taxonomy.term_id = wp_categories.cat_ID

If you didn’t make a backup of the wp_categories table, you can just load the whole backup again and give it a different name. When you run the 2 queries, just prefix the table names with the name of the backup DB.

Update: If you have subcategories, you can try the query I posted in my comment below. I didn’t actually try it myself, so be careful.




Ähnliche Beiträge


18 Kommentare zu “WordPress upgrade to 2.6 deletes all Categories”



  • Wordpress 2.6, problemi con le categorie at Café Moroe am 5. August 2008 3:13 pm Uhr

    […] thanks to Remy Blaettler) tags: 2.6, categorie, fix, […]


  • Wordpress 2.6: Upgrade Causes Broken Categories: Fix Here : Digital-Lifestyles (alpha remix) am 6. August 2008 11:01 am Uhr

    […] a more automated approach, take a look at Remy Blaettler’s description of how he achieved the same in a few lines on […]


  • Simon Perry am 6. August 2008 11:05 am Uhr

    Thanks a lot for writing this one up.

    A life saver as we had 148 cats – much appreciated.

    Only small issue – all the cats are now at top level, not in their Sub cats. Any ideas?


  • Remy Blaettler am 6. August 2008 11:36 am Uhr

    I didn’t try this out, because I had no sub categories in my blog, but I think if you copy the category_parent field into the parent field, it should work:

    UPDATE wp_term_taxonomy, wp_categories
    SET wp_term_taxonomy.description = wp_categories.category_description,
    wp_term_taxonomy.parent = wp_categories.category_parent
    WHERE wp_term_taxonomy.term_id = wp_categories.cat_ID

    Good luck 🙂


  • George Walford » Wordpress broke my catagories am 8. August 2008 12:23 pm Uhr

    […] Solution 1 Solution 2 Using the Google cache I have pulled my categories up (I could have used my MySQL backup, but the Google cache is faster). […]


  • p2e.dk/noter » Blog Archive » Wordpress loss of category names am 14. August 2008 7:59 pm Uhr

    […] The SQL fix is explained here […]


  • Kasper am 14. August 2008 8:04 pm Uhr

    Thanks for sharing 🙂

    Be sure to check youre wp_category table for duplicate values in the slug field (its unique in the new table)


  • Too early to upgrade WordPress to 2.6 easily [UPDATE: fixed] • STEREO.org.ua am 15. August 2008 7:15 am Uhr

    […] Remy Blaettler offered an elegant solution of 3 SQL queries (you’d have to have your wp_categories table backed up before upgrade for a complete […]


  • Mystery am 6. September 2008 8:55 am Uhr

    Tried it but I still have one strange problem…

    Every time I locate the number of a category, and go ahead and try to edit it as in giving it its original name, a number is automatically assigned to it, and therefore it has a new url link that differs from the old one because of that number…

    Say I wanted to name a category: (Review) which is its original name before upgrading and the problem… it will end up being (Review 2) because I think wordpress detects another link with the name review, so it gives it a number which messes everything up! Tried everything to avoid the number being assigned, but no use…

    Can anyone suggest a solution for that?

    Thanks…


  • Paul Voermans am 17. September 2008 8:36 pm Uhr

    Thanks, this is brilliant! Only difference for me was I downloaded my categories as a file and imported it afterwards using phpmyadmin. Ta.


  • Blog Salud am 28. October 2008 4:00 pm Uhr

    Many many thanks! You saved my 206 categories. 🙂


  • Blog am 1. December 2008 2:38 am Uhr

    Very good article


  • web tasarım am 3. June 2009 12:58 pm Uhr

    very tthanks for that post, its very useful for me


  • web tasarımı am 26. July 2009 11:49 am Uhr

    I needed to upgrade from 2.6. I will be very useful. Thank you very much.


  • Endustriyel Otomasyon am 31. August 2009 10:45 am Uhr

    it s very useful, thnxxx


  • alyans am 13. October 2009 6:04 am Uhr

    thanks for sharing…


  • alyans am 15. October 2009 5:36 am Uhr

    nice sharing..thanks..


  • Guate Games am 21. January 2010 2:48 am Uhr

    Thanks, very useful upgrade, problem solved.


Leave a Reply

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



*