Home › Forums › Front-end Issues › get_field_object() add value to select all › Reply To: get_field_object() add value to select all
Thank you very much for your detailed answer.
But for some reason something is not working.
I added the code you posted in functions.php
file
I added the class name acf-need-to-add-all-option
to the field at the acf field management.
This is the code I retrieve the field options to the search form at the front end and where I want to add all the ‘select all’ option.
<div>
<label for="field_59ae96d970a06">Select a city</label>
<?php
$field_key = "field_59ae96d970a06";
$field = get_field_object($field_key);
if( $field )
{
echo '<select name="' . $field['key'] . '">';
foreach( $field['choices'] as $k => $v )
{
echo '<option value="' . $k . '">' . $v . '</option>';
}
echo '</select>';
}
?>
</div>
To be honest I am sure that I am doing something wrong.
*** The code you wrote above adds the All
option to the backend edit field section.
How can I add it to the front end?
Thank you again.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.