• Hi,

    By mistake I deleted a bunch of categories (ID=12,13,14,15,16) from dashboard, so re-created them. The problem is that now the ID starts from 17, which means that the deleted category ID numbers are unusable anymore?? I have many customized page templates and since they are called in based on the ID number it’s a bit pain for me to go back and change the php code everytime something like this happens… Any idea how I can re-use those ID numbers? Many thanks!

    AD

Viewing 8 replies - 1 through 8 (of 8 total)
  • The simple answer is, you can’t.

    Unless you restore your database back to where it was before you deleted them.

    Or find every reference in the database to a current cat ID and replace it with the old ID.

    Or can find a plugin that change cat ID’s. (I don’t know if there is one but there could be.

    Those cat ID’s are stored in a number of places on every transaction involving them, and if you miss one when you change, you will make a mess that will not be fun to clean up.

    So, to revise my original statement, if you get educated on all the places that use the cat ID you can change them. But otherwise you are better off leaving them alone.

    You could just re-set (not reset) the auto-increment for that table, it won’t do any harm, unless you’ve already started creating new categories that you can’t afford to lose..

    IE, if you have …

    5
    6
    7
    8
    12
    13
    14

    Then it’s not an option..

    If that’s not the case, post back and i’ll provide a line of SQL you run from PHPMYADMIN that will set the auto-increment back for you.

    I recently flushed out all my categories, so set mine back to 1… ?? Now i have nicely numbered 1,2,3,4 ids etc..

    Thread Starter Agent D

    (@agent-d)

    Hmm… interesting. Thanks for your suggestions. I think I’m going to just leave as it is. Many thanks. AD

    Note also that as of 2.9, you can use category slugs in your category templates instead of IDs.

    miklb are you referring to new support for using category slugs inside functions such as is_category, and in_category?

    If that’s the case, it certainly makes usage a bit easier… good stuff.. ??

    I was actually referring to the fact that you can now have template files for categories using the slug instead of just the ID.

    is that why cats and tags cannot have identical slugs anymore … annoys me to death.

    I was actually referring to the fact that you can now have template files for categories using the slug instead of just the ID.

    Oh i see, like category-name.php , instead of having to use category-ID.php … ?? Still useful… ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Clean up category IDs?’ is closed to new replies.