我正在构建一个主题选项面板,到目前为止,除了“选择”类型选项外,其他都很成功。这是我的代码:
array( "name" => "Transition",
"desc" => "Choose the type of transition.",
"id" => $shortname."_transition",
"type" => "select",
"std" => \'1\',
"options" => array("0" => "None", "1" => "Fade", "2" => "Slide Top", "3" => "Slide Right"),
现在,我的选择代码是:
<select name="<?php echo $value[\'id\']; ?>" id="<?php echo $value[\'id\']; ?>">
<?php foreach ($value[\'options\'] as $option) { ?><option <?php if ( get_settings( $value[\'id\'] ) == $option) { echo \' selected="selected"\'; } elseif ($option == $value[\'std\']) { echo \' selected="selected"\'; } ?>><?php echo $option; ?></option><?php } ?>
现在,当我将该选项拉入主题时,它会输出选项名称(淡入、滑动顶部…等),而不是值(0、1、2、3)。
我猜也许我错过了value=""
从/option>
密码任何帮助都将不胜感激,谢谢。
Edit: figured it out, edited the second code to this:
<?php foreach ($value[\'options\'] as $key=>$option) { ?><option value="<?php echo $key; ?>" <?php if ( get_settings( $value[\'id\'] ) == $option) { echo \' selected="selected"\'; } elseif ($option == $value[\'std\']) { echo \' selected="selected"\'; } ?>><?php echo $option; ?></option><?php } ?></select>