Home › Forums › ACF PRO › How to assign value for a specific repeater sub field of sub field › Reply To: How to assign value for a specific repeater sub field of sub field
You can also use update field to update the entire repeater all at once. For example
$value = array( // create a nested array for each row of the repeater 'field_0123456789' => array( // this is a nested repeater // again, create a nested array for each row 'field_1234567890' => array( // nested nested repeater // you can do this indefinitely 'field_9840329403284' => 'value of field', 'field_9840329403284' => 'value of field', ) ) // end for nested repeater array ); // end of repeater array
Create some values in a repeater and save them. On the front end of your site do this
echo '<pre>'; print_r(get_field('top_level_repeater')); echo '</pre>';
you can use update_field() https://www.advancedcustomfields.com/resources/update_field/ to push the entire content of the repeater by using the same format for the array value as what the above code will display.
If you are created values where none already exist then you need to replace the field names in the array that is output with the field keys for those fields. And Like I’ve said previously, it is always a good idea to be in the habit or using field keys when using any of ACF’s update functions.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
🚀 This week’s session of ACF Chat Fridays dips into the preliminary results of our first ever user survey. Don’t miss it! https://t.co/3UtvQbDwNm pic.twitter.com/kMwhaJTkZc— Advanced Custom Fields (@wp_acf) May 9, 2023
© 2023 Advanced Custom Fields.