我正在使用woocommercewoocommerce_form_field
功能使用wordpress添加项目。因此,我正在使用选择框type => select
,但是我想显示在初始显示时确定的内容。
示例:假设选择框包含值A
,B
和C
,我希望C
在最初显示时处于选择状态。
我应该如何指定?
woocommerce_form_field(
'XXX',
array(
'type' => 'select',
'required' => false,
'label' => 'OO',
'class' => array('XXX', 'XXX'),
'options' => array(
'a' => 'A',
'b' => 'B',
'c' => 'C'
),
),
);
您可以使用“默认”参数作为参数。
https://rudrastyh.com/woocommerce/woocommerce_form_field.html
woocommerce_form_field(
'XXX',
array(
'type' => 'select',
'required' => false,
'label' => 'OO',
'class' => array('XXX', 'XXX'),
'options' => array(
'a' => 'A',
'b' => 'B',
'c' => 'C'
),
'default' => 'c'
),
);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句