Hello,
For the option group, it isn't possible. But you can try to set the sub-choices like this
function my_custom_callback() {
return [
[
'value' => 'monkeys',
'label' => 'Monkeys',
],
[
'value' => 'king_kong',
'label' => 'King Kong',
'parent' => 'monkeys',
],
[
'value' => 'curious_george',
'label' => 'Curious George',
'parent' => 'monkeys',
],
[
'value' => 'donkeys',
'label' => 'Donkeys',
],
[
'value' => 'eeyore',
'label' => 'Eeyore',
'parent' => 'donkeys',
],
[
'value' => 'guss',
'label' => 'Gus',
'parent' => 'donkeys',
],
];
}
and set the setting flatten
to false
. Follow the documentation https://docs.metabox.io/fields/select/#settings