Get the label from ACF checkbox [closed]

You can try this

$field = get_field_object('color'); 
$colors = get_field('color'); // array of selected color values 
foreach($colors as $color){
    echo "selected color: ". $color. " with label: " . $field['choices'][ $color ];
}

where the labels are fetched by get_field_object according to the link you provided.

You could also use print_r() or var_dump() to check what is stored in the variables $field and $colors.

Leave a Comment