How to update all post at once?

Try this out:

/*
Plugin Name: Post Bulk Update
Description: Updates certain fields of my posts at once. On Activation. Awesome
Author: Me. I did it
*/
add_action('init','post_bulk_update');

function post_bulk_update(){
 $posts_to_update = new WP_Query('cat=x&showposts=1000');
while($posts_to_update ->have_posts()) : $posts_to_update ->the_post();
$postUpdateArray = array();
$postUpdateArray ['ID'] = $post->ID;//Don't remove this. The ID is mandatory
$postUpdateArray ['post_title'] = 'Post Prefix: '.$post->post_title;
     wp_update_post( $postUpdateArray );
endwhile;

}

For more reference see this.

Leave a Comment