WordPress.org

Forums

HOW TO: Change Category ID's in WordPress 2.7 (7 posts)

  1. peterluxford
    Member
    Posted 6 years ago #

    I recently needed to change my category ID's in WP 2.7 to make sure my MIMBO theme using VIVA Thumbs plug-in chose the right default category image if 2 categories were added to a post, as it chooses the one with the lowest number.

    Seeing as I have no MYSQL knowledge it is remarkably simple - here's how.

    1. Make a full backup of your database in case something goes wrong. I use - This Wordress Database Backup plug-in.

    2. Write down all your categories and their current ID's. You can find them out by going to the category section of your WordPress Dashboard and hovering over the category names. The ID will appear in the bottom of the browser window.

    3. Access your database with phpmyadmin.

    4. Select the wp_terms table and locate the Categories by their term_id number.

    5. Click the pencil icon and change each term_id value to the desired number. Choose high numbers to avoid clashing with other ID's for tags or link categories etc. I choose 1010, 1020, etc.

    6. Then select the wp_term_taxonomy table.

    7. Go through this database and locate the entries with the OLD term_id values of your categories and edit them to read the same as the term_id values you just entered in the previous step.

    8. You are now done. All your posts associated with those categories should still be so.

    9. You will now need to go through your template and replace any category specific codes.

  2. ginntonic
    Member
    Posted 6 years ago #

    Thanks so much for the walk-through!

    It's exactly right.

    Best,
    TN

  3. evakenney
    Member
    Posted 6 years ago #

    Do you know how to change Page IDs? Would it be the same process?

  4. hotbelgo
    Member
    Posted 6 years ago #

    I'm doing something wrong because get_categories seems to be returning results in the order of term_taxonomy_id rather than term_id. Any ideas what I could be doing wrong?

  5. hotbelgo
    Member
    Posted 6 years ago #

    I'm using 2.7.1 and verified that, with just two categories, get_categories() does not respect a renumbering such as

    100 -> 102
    101 -> 101

    Instead it seems to insist on alphabetic ordering even with order_by=ID too.

  6. hotbelgo
    Member
    Posted 6 years ago #

    woops, was using order_by rather than orderby

  7. grpsmglr00
    Member
    Posted 5 years ago #

    you can also download the [GWA] db Editor plugin and access the database directly in the wp-admin.

Topic Closed

This topic has been closed to new replies.

About this Topic