Support

Account

Home Forums Front-end Issues Displaying multiple select field labels Reply To: Displaying multiple select field labels

  • Hey wearegiants,

    thank you for this hint. Actually with your piece of code you only get the label of a single selected value.

    Use this code if you want to store all labels in one array ($labels):

    $labels = array();
    $field = get_field_object('fieldname');
    $values = get_field('fieldname');
    foreach ($values as $value) {
       $labels[] = $field['choices'][ $value ];
    }

    For outputting the labels:

    foreach ($labels as $label) {
       echo $label;
    }