I'm running a function to populate some custom fields with some values specified:

add_filter('acf/load_field/name=event_end_time', function($endField) {
    $endDate = get_field('event_end_date');
    $endHour = get_field('event_end_hour');
    $endMinute = get_field('event_end_minute');
    $endMeridian = get_field('event_end_meridian');
    $end12 = $endHour . ':' . $endMinute . $endMeridian;
    $end24 = date("H:i:s", strtotime($end12));
    $finalEndDateTime = $endDate . ' ' . $end24;
    $endField['value'] = __($finalEndDateTime, 'txtdomain');
    return $endField;   

This populates the field event_end_time as expected and the desired values appear in the field as expected...which is great. But none of these values appear on the front-end until I go in and manually 'Update' each post.

What I'm trying to find out, but not succeeding, is whether it's possible to expand this function to 'update' the posts too so I don't have to go in and hit update myself on 500-600 posts?

1 Answer 1


This is the normal behavior.

ACF field value will not be added directly in your post until you save it. I've been facing this "issue" lately.

this is because you have created your field after your posts. So, your posts don't have the associated value.

load_field doesn't add values on existing post, it only add your value on the post form edition.

What I suggest, is that you can do a one-shot function that update all your posts in a second.

foreach(get_posts($args) as $post) {
  $data[] = ... // your event data
  update_field('your_field_group', $data, $post->ID); 

be careful here, you might want to use add_row function instead of the update_field (depending on your needed) https://www.advancedcustomfields.com/resources/add_row/

Not the answer you're looking for? Browse other questions tagged or ask your own question.