0

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? enter image description here

0
  • Back-up your db
  • 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');
    
  • Refresh
  • Remove the code

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.