============ post object field
I’m writing a migration script and I need to populate the above fields.
I tried add_row, add_sub_row, update_field but nothing works.
I saw this answer in SO where it says you need to use update_field if there are no rows and add_row if there are.
So I tried this:
$res = update_field(
// parent group field
'ingredients_groups' => [
and a row was added to ‘ingredients_groups’ but I don’t know how to add
rows to the other nested repeaters.
Do I need to specify the full path when calling update_field like this:
OK got it to work.
I used update_field() to add the first row with all the sub fields and nested repeater as arrays.
For the next rows I fetched the entire parent group field using get_field()
and appended the row as array.
If this was me I would probably loop through all of the content you are getting and build the entire repeater with all rows and then just use update_field to store the entire thing and skip adding all of the other rows one at a time. You do not have to use add row.
Viewing 3 posts - 1 through 3 (of 3 total)
The topic ‘update multiple nested repeaters programmatically’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users