WordPress.org

Ready to get started?Download WordPress

Forums

MySQL command for changing category IDs (7 posts)

  1. thepete
    Member
    Posted 8 years ago #

    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. :)

  2. Austin Matzko
    Member
    Posted 8 years ago #

    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.

  3. thepete
    Member
    Posted 8 years ago #

    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?

  4. charle97
    Member
    Posted 8 years ago #

    backup your db before executing the sql.

  5. thepete
    Member
    Posted 8 years ago #

    Ah, yes--good point. :)

  6. Austin Matzko
    Member
    Posted 8 years ago #

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

  7. geoffe
    Member
    Posted 8 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags