Home › Forums › General Issues › get_field() doesn't return a value when fields are created with update_field() › Reply To: get_field() doesn't return a value when fields are created with update_field()
The problem is that the post and the custom fields associated with the post do not exist yet so
update_field() is not able to set the field key properly. You also can’t get the field object using the field name for the same reason.
I think that the documentation explains it all pretty well. http://www.advancedcustomfields.com/resources/update_field/
All you really need to do is edit
$customFields = [...] // Associative array of field's names and values
to use field keys instead of field names.
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!