When you use update_field()
on a field that has not data it is not updated correctly if you use the field name. When calling update_field()
for fields that were not previously set you must use the field key. update_field($field_key, $vale, $post_id)
This is explained in the documentation https://www.advancedcustomfields.com/resources/update_field/