WordPress.org

Support

Support » How-To and Troubleshooting » MySQL command for changing category IDs

MySQL command for changing category IDs

  • Hey, I’m anal and need all of my category IDs in order from 1-20, but I’ve deleted a bunch of categories and now when I add one it doesn’t take the lowest number not being used.

    Now, I’ve searched the forum, but can’t find the specific MySQL command, which is all I’m looking for. I’m comforable in phpmyadmin so I’d just like to do it that way–unless there is a plugin for this, which would rock. 🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • At your own risk:

    UPDATE wp_linkcategories SET cat_id='1' WHERE cat_id='2'

    That will change id 1 to 2.

    Of course if you’re doing this, you’ll probably want to change the stuff in wp_post2cat, too.

    Ah, cool! Thanks!

    So to do it with wp_post2cat, I just use this command:

    wp_post2cat SET cat_id=’1′ WHERE cat_id=’2′

    I assume that’s right?

    backup your db before executing the sql.

    Ah, yes–good point. 🙂

    Oops, I got that backward. I meant to say it would change it from 2 to 1. 🙂

    The column name for post2cat is category_id not cat_id (although you likely figured that out looking at it). And if you are changing post categories, you’ll want to edit wp_categories, not wp_linkcategories.

    And don’t forget UPDATE at the beginning of your query, thepete.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘MySQL command for changing category IDs’ is closed to new replies.
Skip to toolbar