Support

Account

Home Forums Front-end Issues More issues with update_field($field_name) not retrieving value Reply To: More issues with update_field($field_name) not retrieving value

  • According to this document http://www.advancedcustomfields.com/resources/update_field/

    So when can I use $field_key?

    You can and should use the $field_key 100% of the time.

    The problem with using $field_name is that if the reference does not already exist, ACF will not be able to find the field object and will not be able to save the value. This situation would occur if you had used code to insert a post.

    Also, it is more efficient to use the field_key as the first parameter in the update_field function as it bypasses the reference look up.

    I know that you’d like to use the field name, but it is better to always use the field key when updating fields to avoid the problems that you’re seeing.