Home › Forums › Front-end Issues › How to Display all fields in a group › Reply To: How to Display all fields in a group
this is the code I got working for anyone interested…
private function display_field_selects(){
$field_group_key = 'group_5b9b435363912';
$fields = acf_get_fields($field_group_key);
echo '<form id="category_filter">';
foreach ($fields as $field => $data){
echo '<div class="category_wrapper">';
echo '<p class="field_label">'.$data['label'].'</p>';
echo '<select id="ms_'.$data['name'].'" multiple>';
foreach ($data['choices'] as $key => $value ){
echo '<option value="'.$value.'">'.$key.'</option>';
}
echo '</select>';
echo '</div>';
}
echo '</form>';
}
This pulls the correct field group data and creates a dropdown select for each field and its options. I believe it will work only on Radio and Checkboxes.
The next phase for me now is to either get the field_key automatically or create a function that can retrieve the appropriate field_group_key from a predetermined list.
Thanks John!
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.