Hey All
Been trying to solve this and you guys might know!
I am trying to print a list of the checkboxes into a unordered list and I want to be able to style each individual list item so they all need a unique class. So I have this.
<?php
$field = get_field_object(‘facilities’);
$value = get_field(‘facilities’);
$label = $field[‘choices’][ $value ];
echo ‘<ul class=”facts”>’;
foreach( $value as $p ){
echo ‘<li class=”‘.$l.'”>’.$p.’‘;
}
echo ‘‘;
?>
This at the moment only prints the value of the check box but I need to also print the label at the same time.
I want the value to be the class name and the label to be what is shown in the bullet list. At the moment I can only seem to get the value from the array and not the label and I can not do it all in the same loop.
My php is not advanced so your help would be great.
$field = get_field_object('facilities');
echo '<ul>';
foreach ($field['choices'] as $value => $label) {
echo '<li>',$value,' => ',$label,'</li>';
}
echo '</ul>