Here is a quick hack to update an ACF (Advanced Custom Fields) field in WordPress.
Place this in functions.php:
// Update all post
function update_all_posts() {
$args = array(
'post_type' => 'event', //or post, page etc
'numberposts' => -1
);
$all_posts = get_posts($args);
foreach ($all_posts as $single_post){
//Example
$value = get_field('event_date', $single_post->ID);
update_field('event_date', date("Ymd", $value), $single_post->ID);
}
}
add_action( 'wp_loaded', 'update_all_posts' );Now refresh the Wordpress page then delete the code from functions.php (or it will run on every page load).
Credit goes to https://marameodesign.com/insights/little-known-hack-to-update-all-posts-or-pages-in-wordpress-by-code/