Support » Fixing WordPress » Category hacking, looking for ideas

  • 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?

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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)


    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.

    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.

    Ah. Bless auto-increment, huh?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Category hacking, looking for ideas’ is closed to new replies.