Support

Account

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 🙂