Batch edit post data and titles wordpress custom post types type
<?php
$loop = new WP_Query( array(
'post_type' => 'page',
'posts_per_page' => -1
)
);
?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php
$title = get_the_title();
$my_post = array(
'ID' => get_the_ID(),
'post_title' => explode(" ", get_the_title())[0],
);
wp_update_post( $my_post );
?>
<?php endwhile; wp_reset_query(); ?>