So I’m in the process of converting Randomjunk over to a WordPress blog, since it seems the main thing I use it for nowadays is quotes (which used to be stored way down under my AIM subprofile that no one uses anymore).
After several hundred posts, I noticed that there was an option for post format, one of which was the “Quotes” type. Unfortunately, WordPress 3.2 mass edit does not include a way to mass update post formats. Therefore, to the SQL.
All of the posts I wanted to convert already had a tag called “Quotes”. Looking in the database in the wp_terms table told me the number of this tag.
SELECT term_id FROM `wp_terms` WHERE name='Quotes';
This ended up being 9.
I also got the term id for the post format I wanted.
SELECT term_id FROM `wp_terms` WHERE name='post-format-quote';
This ended up being 86.
Therefore, I just run this query on the relationships table:
INSERT INTO `wp_term_relationships`(object_id, term_taxonomy_id, term_order) SELECT object_id, 86, 0 FROM `wp_term_relationships` WHERE term_taxonomy_id=9;
I also needed to fix up the term_taxonomy table
SELECT count(1) FROM `wp_term_relationships` WHERE term_taxonomy_id=86;
gave me 337 rows, so
UPDATE `wp_term_taxonomy` SET count=337 WHERE term_taxonomy_id=86;
Done. Yay.