Support

Account

Home Forums Front-end Issues Display values as a list

Solved

Display values as a list

  • Greetings from Brazil 🙂

    Is there a way to display the values of a field that can have multiple answers (like checkboxes, f.e.) stacked instead of plain text?

    Today it would appear as A, B, C

    I would like them to show up as
    A
    B
    C

    Thanks in advance!

  • 
    <?php 
    $values = get_field('checkbox');
    if ($values) {
      ?>
        <ul>
          <?php 
            foreach ($values as $value) {
              ?><li><?php echo $value; ?></li><?php 
            }
          ?>
        </ul>
      <?php 
    }
    ?>
    
  • Hi John, thank you for your reply!

    I added the code you wrote as a snippet to functions.php but when I activate it, I get a 500 error.

    Am I doing this in the wrong way?

  • I have no idea why your getting an error. This was just an example. But when getting fields to display the code should be in the template that shows the values, not in functions.php

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.