Hi, I’ve a checkbox field with options like:
red_color : Red
blue_color : Blue
...
I need to print both the value (‘red_color’) and the label (‘Red’). I’ve tried this code from the documentation but it doesn’t work:
<?php
$field = get_field_object('color');
$colors = get_field('color');
foreach($colors as $color){
echo "<br>Selected color: ". $color. " with label: " . $field['choices'][ $color ];
}
?>
The output is:
selected color: Red with label:
selected color: Blue with label:
How can solve it?
Thanks