I’m trying to use update_field to change a value in a sub field with the following code but it is not changing. This is my following code:
if( get_field('image_gallery', $id) )
{
while( has_sub_field('image_gallery', $id) )
{
update_field('field_4f7b11d3e7729', 10702, $id);
echo get_sub_field('image');
}
}
I’m expecting “10702” to be printed but it’s original value isn’t changing.
This is my repeater field:
array (
'key' => 'field_9',
'label' => 'Image Gallery',
'name' => 'image_gallery',
'type' => 'repeater',
'order_no' => 1,
'instructions' => '',
'required' => 0,
'conditional_logic' =>
array (
'status' => 0,
'allorany' => 'all',
'rules' => 0,
),
'sub_fields' =>
array (
0 =>
array (
'key' => 'field_4f7b11d3e7729',
'label' => 'Image',
'name' => 'image',
'type' => 'image',
'save_format' => 'id',
'preview_size' => 'thumbnail',
'order_no' => 0,
),