in acf for the select field how do i get it to list all the choices in it using php.
I’m struggling as well to retrieve this kind of data. Did you manage to find a solution?
Hi guys,
This is something you can accomplish using get_field_object(...)
function. get_field_object(...)
will return a field object. You can get the choices using the following code:
$field = get_field_object('select_field', 1);
$choices = $field['choices'];
foreach($choices as $choice):
echo $choice;
endforeach;
For more information on this, have a look at: http://www.advancedcustomfields.com/resources/get_field_object/
Couldn’t get that code to work but the Get a field object and create a select form element
code at the end of the get_field_object/ link was a success.
Thanks.
Thank you for sharing your information, information is power and time discounted, again thank you
What does:
'select_field'
mean? Is that where I put something in like “company”?
Justin
Thanks James! It helped me figure out my issue. Code is from here: https://www.advancedcustomfields.com/resources/get_field_object/