I have 350 posts that were using a plugin-provided option stored in a meta_key ("custom_post_template", to be precise).
I want to convert these posts to assign them a specific post_format ("gallery").
I could do it one by one, but it's going to take ages (there are 4000+ posts), so i'm looking at a clever SQL query that could do that.
Right now, i have found how to retrieve the 350 posts that were using the old system:
SELECT *
FROM `wp_postmeta`
WHERE `meta_key` LIKE 'custom_post_template'
But i don't understand where Wordpress keeps track of the post_format-to-post association. What would be the SQL query?