Skip to content

Instantly share code, notes, and snippets.

@vol4ikman
Created April 3, 2017 08:32
Show Gist options
  • Save vol4ikman/81476fc19d06e460d821ad5d17711734 to your computer and use it in GitHub Desktop.
Save vol4ikman/81476fc19d06e460d821ad5d17711734 to your computer and use it in GitHub Desktop.
Update subfields ACF
<?php
$fields = array();
// $dates = array of subfields to update
// $post_id = where to update fields
$repeater_key = 'field_58e1e3a5fe92f';
foreach( $dates as $tour_date ) {
$date = get_converted_date( $tour_date['schedule-date'] );
$from = $tour_date['schedule-from'];
$until = $tour_date['schedule-until'];
$fields[] = array(
'date' => $date,
'time_from' => $from,
'time_until' => $until,
);
}
if( $fields ) {
update_field( $repeater_key, $fields, $post_id );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment