Home › Forums › Feature Requests › REST API › Reply To: REST API
Looking at your code over there, the biggest thing that I see when it comes to ACF is that you’re using the field name when updating the ACF fields.
When a post and the ACF field values does not previously exist, using update_field() using the field name will fail because ACF does not know what to do with the value.
When using update_field() in this situation you need to use the field key instead of the field name.
You could also use update_post_meta() and add everything that ACF will need. When ACF adds a value to the field it inserts 2 rows in the database:
meta_key | meta_value
{$field_name} | $value
_{$field_name} | $field_key
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.