How can I mass-update/save all WordPress posts and pages?

Add to your functions.php file, but dont forget to take it off after use it !!!!!

function update_all_posts() {
    $args = array(
        'post_type' => 'post',
        'numberposts' => -1
    );
    $all_posts = get_posts($args);
    foreach ($all_posts as $single_post){
        $single_post->post_title = $single_post->post_title.'';
        wp_update_post( $single_post );
    }
}
add_action( 'wp_loaded', 'update_all_posts' );

PS : BE SURE TO MAKE A DATABASE BACKUP BEFORE EXECUTE !!!

Leave a Comment