Created
April 3, 2017 08:32
-
-
Save vol4ikman/81476fc19d06e460d821ad5d17711734 to your computer and use it in GitHub Desktop.
Update subfields ACF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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