我使用相同的选项框架插件,这就是我使用该框架指定选择菜单的方式;
$test_array = array(
\'one\' => __(\'One\', \'options_framework_theme\'),
\'two\' => __(\'Two\', \'options_framework_theme\'),
\'three\' => __(\'Three\', \'options_framework_theme\'),
\'four\' => __(\'Four\', \'options_framework_theme\'),
\'five\' => __(\'Five\', \'options_framework_theme\')
);
$options[] = array(
\'name\' => __(\'Select a Tag\', \'options_check\'),
\'desc\' => __(\'Passed an array of tags with term_id and term_name\', \'options_check\'),
\'id\' => \'example_select_tags\',
\'type\' => \'select\',
\'options\' => $test_array);
请注意
options
参数接受;
\'options\' => array(\'value\' => \'label\')
在您的实例中,您仅使用指定的标签;
\'options\' => array(\'blue\', \'yellow\')
这意味着蓝色的值为
0
黄色的值为
1
.
因此,以下内容不正确,
if ( of_get_option(\'color_scheme\') == "blue")
应该是这样的,
if ( of_get_option(\'color_scheme\') == 0) //0 for blue 1 for yellow
如果要使用蓝色或黄色的值名称进行检查,那么数组应该如下所示:,
\'options\' => array(
\'blue\' => \'Blue\',
\'yellow\' => \'Yellow\'
)