Support

Account

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