Home › Forums › Front-end Issues › Adding Separators to Select-Field Options › Reply To: Adding Separators to Select-Field Options
Hi @dtx211
I believe your approach is the best way to do it. But please keep in mind that ACF won’t allow you to have multiple choices with the same value.
You can also group the choices by modifying them using the acf/load_field hook. It should be something like this:
function acf_load_color_field_choices( $field ) {
// grouped choices
$field['choices']['Fruit'] = array('Apple', 'Banana', 'Grapes', 'Oranges');
$field['choices']['Dairy'] = array('Cheese', 'Yoghurt');
// return the field
return $field;
}
add_filter('acf/load_field/name=select', 'acf_load_color_field_choices');
I hope this helps 🙂
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.