Home Forums General Issues Display Value of Radio Button


Display Value of Radio Button

  • There seams to be documentation on how to display all, but radio button, fields.
    How do I go about displaying the values of my radio buttons, regardless of whether they are selected or not.
    The radio button is within a repeater field – I want to display the value outside of this loop so it’s not shown repeated times.

  • I second this. With the code provided for the checkboxes there is no result, but just using the_field('field_name'); gives me the correct results. But I need more output, so should we use a switch-statement?

  • Yes, documentation on radio buttons would be nice! 🙂

  • It’s probably not at first obvious, but the Radio field type is just a normal select field type. That’s probably why there isn’t separate documentation for it. The only difference between the two (Radio vs. Select) being that Radio only allows one choice (and at least one thing must be chosen). They should still work the same.

    This will display your choice:
    <?php the_field('example'); ?>
    This will display the possible choices:
    <?php echo implode(', ', get_field_object('example')[choices]); ?>

    If you head on over to the select documentation, the examples should get you going.

  • Thanks, LingoSam. I would say that’d make a great page to add for people like me for whom it’s not that obvious 🙂 or could probably figure it out, but like to have things printed in black and white to fall back on 🙂

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

The topic ‘Display Value of Radio Button’ is closed to new replies.