Category hacking, looking for ideas (5 posts)

  1. Chris_K
    Posted 10 years ago #

    I have a huge mess of categories. I want to simplify things a bit and reorg down to just a handful of 'em.

    Of course, deleting a category does the "honest, I won't delete your posts, I'll just move them to the default category." Fair 'nuff. However, the category I'm deleting is a sub-category of one of the few I wish to keep. Well, now it is in the "kept" category and "Uncategorized".

    Trying to think of a tolerably efficient way to accomplish this without editing each post, 1 by 1. Any ideas or tips?

  2. Chris_K
    Posted 10 years ago #

    Ah... is this all in the post2cat table? That would make it simple.
    Delete from post2cat where cat_id not in (comma sep list of categories I want to keep)


  3. vkaryl
    Posted 10 years ago #

    I don't know.... for all my dinking around in databases over the years, I've never tried to do anything similar to this.

    If you don't get an answer here within a "reasonable" space of time, try posting to wp-testers; someone there might be able to help.

  4. Chris_K
    Posted 10 years ago #

    Well... I tried it. :-)

    And, it pretty much even kinda sorta worked. When I go to the manage posts section, all the cruft is gone and the posts are only in the categories that I didn't purge from wp_post2cat. Good stuff.

    Of course, now I see that we also store category_count in the wp_categories table (I'll spare the normalization rant...but geeze). So... now to ponder how to update those.


    Duh. By hand! I only have 5 categories left and the totals are in my current theme's sidebar. that'll probably work.

    Even better. On a whim, I edited one post. After the save, the category counts all updated. Sweet.

  5. vkaryl
    Posted 10 years ago #

    Ah. Bless auto-increment, huh?

Topic Closed

This topic has been closed to new replies.

About this Topic