Returning all radio button options when using Advanced Custom Fields

Check out this page in order to discover your field key for your radio button: http://www.advancedcustomfields.com/docs/functions/get_field_object/

Next, insert this code where you are grabbing your field values:

<?php
 $key = 'your_fieldkey_here';
 $field = get_field_object($key); 
 if ($field) {
       foreach ($field['choices'] as $key => $value) {
        echo ('KEY : ' . $key);
        echo ('<br />');
        echo ('VALUE : ' . $value);
        echo ('<br />');
      }                             
   }
?>

This code will return your set of keys and values.

This only issue with this method is that it will not work if your radio button field is inside of a repeater field.

Leave a Comment