Support

Account

Home Forums General Issues Displaying Multiple Values & Labels

Solving

Displaying Multiple Values & Labels

  • Hey guys,
    So I’ve been really digging almost all of ACF’s functionality, but have gotten stuck on a way I’m trying to use checkbox choices.
    What I want to achieve is a list of checkbox choices with website links as values and region names as labels.

    I saw in the checkbox documentation that there is a way to display a single value and it’s label and a way to display multiple values, but I didn’t see anything regarding displaying multiple labels.

    Ideally what I want to accomplish is use each checkbox to display a button with the text from the label and the value as a link for that button.

    Any help would be greatly appreciated,
    Thanks!

  • This should get you on the right track, just modify the echo to make a button:

    
    <?php
      $full_object = get_field_object('field_name_here');
      
      foreach($full_object['value'] as $value){
        
        // $value is the 'value'
        $label = $full_object['choices'][$value];
    
    } ?>
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.