Support

Account

Home Forums General Issues Strange Behavior with field data and get_field Reply To: Strange Behavior with field data and get_field

  • Actually, yes, when using update_field() is is best to assume that the field has no value and always use the field key.

    The documentation should actually say that in my opinion, but not much I can do about that.

    Any value in the database, even an empty string. What matters is that ACF creates two entries in the database, one has a meta_key of your field name and the other has a meta_key of your field name prepended with an underscore _{$field_name}. If both of these exist then you can use the field name. ACF actually uses the field key for everything because they are unique. Field names are only provided for our convenience. If you look at an admin page with fields and inspect you will find that all of the inputs use the field key for the field name.

    The only time this is not the case is when using an acf/save_post with a priority of > 10 and you can be sure that ACF has already created a DB entry for the field and you intend to change it for some reason.