Support

Account

Home Forums ACF PRO Select field Help

Solving

Select field Help

  • /*
    *  Displaying a single value's Label
    */
    
    $field = get_field_object('field_name');
    $value = get_field('field_name');
    $label = $field['choices'][ $value ];

    Hi, I want to retrieve de label of a selected field and it seem that the code above take from documentation do it, but Im using it with my filed_name, and is not working. I really dont know what is [‘choices’], but is not working with my field name. Some help will be awesome.

  • Hi @dedalos-01

    Can you confirm that you have replaced ‘field_name’ with your field’s name?
    Can you paste you actual code, not the documentation?
    Can you please also debug your code line by line and confirm all the data is returned and correct?

    Thanks
    E

  • Hi Elliot, finally I get the data from the array in this way:

      if( is_array($checkbox_options)&& in_array( 'show_grid_bp', $checkbox_options ) ) {
        echo "border-right:dotted 1px black;";
        } else {
        echo "border:none;";}

    , I still don’t understand very well the docs, could you use the data above and use your code, so I can see?

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.