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.

                        <label for="field_59ae96d970a06">Select a city</label>
                            $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>';

    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.