Php Can';t获取第一个下拉列表值(但获取其余值)
我正在Php Can';t获取第一个下拉列表值(但获取其余值),php,arrays,wpbakery,Php,Arrays,Wpbakery,我正在wp bakery中构建一个自定义元素,结果与下拉字段混合 字段: array( 'type' => 'dropdown', 'heading' => __("Text align"), 'param_name' => 'text_align', 'description' => 'Select the alignment of the text.', 'value' => array( 'Left' =
wp bakery
中构建一个自定义元素,结果与下拉字段混合
字段:
array(
'type' => 'dropdown',
'heading' => __("Text align"),
'param_name' => 'text_align',
'description' => 'Select the alignment of the text.',
'value' => array(
'Left' => 'left',
'Center' => 'center',
'Right' => 'right'
),
'std' => 'left',
'admin_label' => false,
'group' => __('Content', 'my-text-domain'),
)
<div text-<?php echo $text_align; ?>>
我如何显示字段:
array(
'type' => 'dropdown',
'heading' => __("Text align"),
'param_name' => 'text_align',
'description' => 'Select the alignment of the text.',
'value' => array(
'Left' => 'left',
'Center' => 'center',
'Right' => 'right'
),
'std' => 'left',
'admin_label' => false,
'group' => __('Content', 'my-text-domain'),
)
<div text-<?php echo $text_align; ?>>
如您所见,wp bakery
中默认值的std
应该是数组值的名称(键)。因此,您需要:
...
'value' => array(
'Left' => 'left',
'Center' => 'center',
'Right' => 'right'
),
'std' => 'Left', // Notice the capital L
...
啊,该死,我肯定我试过了,我想我的页面还是被缓存了。尽管如此,它现在正在发挥作用。谢谢:)