Meta Box
Support Forum
Support › General › Set Selected by default in Radio box
I have this code
array( 'id' => $prefix.'featured_product', 'name' => 'Featured Product', 'type' => 'radio', 'options' => array( 'yes' => 'Yes', 'no' => 'No', ), ),
I want to make "No" as selected by default.. how to do it?
Just add 'std' => 'no' to the field 😉
'std' => 'no'
I did not understand I have an input of type radio: Man (x) Woman (_) How do I do this?
Hi Nuno,
You just need to define the field like this:
array( 'id' => 'field_id', 'name' => 'Gender', 'options' => array( 'm' => 'Man', 'w' => 'Woman', ), 'std' => 'm', )
Not work 🙁
array ( 'id' => 'sexo', 'name' => 'Sexo', 'type' => 'radio', 'std' => 'Homem', 'options' => array( 'Homem' => 'Homem', 'Mulher' => 'Mulher', ), 'required' => 1, ),
Probably, you're on an old post or your meta box has already been saved. See this for more details:
https://docs.metabox.io/field-settings/#default-value