
Hello. How can i update the fields? I tried the following code, but it doesn’t work
if( have_rows('main_specifications', $product_id) ):
while ( have_rows('main_specifications', $product_id) ) : the_row();
if (update_sub_field('colors', 'some value')){
echo 'successful';
}
endwhile;
else :
echo 'no rows found';
endif;
and if i try this code it works:
if( have_rows('main_specifications', $product_id) ):
while ( have_rows('main_specifications', $product_id) ) : the_row();
$sub_value = get_sub_field('colors');
print_r($sub_value);
endwhile;
else :
echo 'no rows found';
endif;
So if i try to get the field value it works but it doesn’t work if i try to update its value.
the “colors” sub field is an array value?
Then you must supply an array when updating the value. But it can be more complicated dependent on what type of field “colors” actually is.