Home Forums Front-end Issues Get Select Field Options Reply To: Get Select Field Options

  • No, you are correct. Regardless of the time of field, it the field does not exist, especially a field like a taxonomy field that contains more than simple text, you cannot get the value of the field after using update_field() with the field name. ACF cannot create the field key reference and this is why the field appears blank even when it has content. You need to use the field key to do the updates. It is possible to get the field keys, you are already using the field name, that you have to code in some way, you just need to substitute the field keys.

    Generally when I need to do this I create an array that holds field name => field key pairs

    $fields_refs = array(
      'name of field 1' => 'field_123456',
      'name of field 2' => 'field_234567',
      // etc...

    Then I can do something like

    update_field($field_refs['name of field 1'], $value, post_id);