Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

  • 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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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