Hi I am working on a site that has over 1500 posts. Many of those posts are in the gallery post format, but I need to change them to the "Standard" format to work with the clients current theme.
Is there any way I can automate this?
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityHi I am working on a site that has over 1500 posts. Many of those posts are in the gallery post format, but I need to change them to the "Standard" format to work with the clients current theme.
Is there any way I can automate this?
Add this code to your functions.php file from your theme:
$all_posts = get_posts(array(
'numberposts' => -1,
'post_type' => 'post',
));
foreach($all_posts as $p)
set_post_format($p->ID, 'standard');
Or with a SQL command:
UPDATE `term_relationships`
SET term_taxonomy_id = 'standard_post_format_id'
WHERE term_taxonomy_id = 'gallery_post_format_id'
Change standard_post_format_id
and gallery_post_format_id
with the IDs matching post format names from the term_taxonomy/terms tables