Skip to content

Instantly share code, notes, and snippets.

@billerickson billerickson/functions.php Secret
Created Jul 11, 2019

Embed
What would you like to do?
<?php
/**
* Bulk update posts
*
*/
function be_bulk_update_posts() {
$loop = new WP_Query( array(
'posts_per_page' => 9999,
) );
if( $loop->have_posts() ): while( $loop->have_posts() ): $loop->the_post();
if( has_post_thumbnail() ) {
$image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' );
if( !empty( $image[1] ) )
update_post_meta( get_the_ID(), 'be_featured_image_width', intval( $image[1] ) );
}
endwhile; endif; wp_reset_postdata();
}
add_action( 'wp_footer', 'be_bulk_update_posts' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.