This is a read-only archive!

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.)

September 14, 2006 @ 4:08 AM PDT
Cateogory: Linux


Quoth Nicole on September 15, 2006 @ 5:10 AM PDT

Et voil?? Quel est ton probl?me?

Quoth Brian on September 15, 2006 @ 6:29 AM PDT