Re-categorizing lots of WordPress entries

I decided to add a "Gentoo" tag to each post in my WordPress blog that has a "Linux" tag on it now. Reason being that Gentoo is the only Linux flavor I use, and Gentoo deserves some lovin'.

However I didn't want to just change the name of the "Linux" category to "Gentoo". I was afraid it would mess up my permalinks. WordPress doesn't really have "tags", they're really categories. So I figured I'll just keep both; both tags are applicable anyways. But re-tagging 50+ entries manually doesn't seem like a lot of fun, does it?

So I made a new category called Gentoo. Then I ran a query similar to

INSERT INTO wp_post2cat (post_id, category_id)
   SELECT post_id as post_id, 33 as category_id
   FROM wp_post2cat
   WHERE category_id = 5

where 33 is the ID of the Gentoo category, and 5 is the ID of the Linux category. Now, each post tagged "Linux" is also tagged "Gentoo". The other thing to do is edit the category_count field value in wp_categories, for the Gentoo category. It was 0, so I set it to the number of posts it should have.

Et voilà. (And now, I get to add a SQL tag! New tags are always exciting.)

2 Responses to “Re-categorizing lots of WordPress entries”

  1. Quoth Nicole:

    Et voilà? Quel est ton problème?

  2. Quoth Brian:

    wha

Leave a Reply

You can use these tags in comments (Note: HTML is automatically escaped inside <pre> tags, nowhere else, so if you post source code, put it in <pre>):

<pre lang="some_programming_language"> 
<em>
<strong>
<a href="url">

NOTE: Comments are automatically spam-filtered. If your comment fails to appear, it was likely munched by the filter. Try not to link-spam or post anything that looks like it was typed by a robot.