Home › Forums › General Issues › Strange Behavior with field data and get_field › Reply To: Strange Behavior with field data and get_field
I have found that if I go to the record with null value from the above function and click UPDATE and then go back and run the above function, the number is there. It is like the number is there but isn’t at the same time. Just wondering what could possibly be the problem.
When this happens it is usually because the field was updated incorrectly. If a field is updated using update_field() and the field for the post it is attached to does not have a value in the database then you must use the field key when calling update_field(). You cannot use the WP function update_post_meta() or any equivalent function to update fields that do not already exist in the database. If you do then you must also add the field key reference to the database yourself.
See this section of the update_field() documentation for an explanation of field key reference https://www.advancedcustomfields.com/resources/update_field/#updating-via-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.