我在WordPress中玩自定义元框,当我试图修改下拉菜单并保存选项时,它不会保存。
如果我使用默认模板,它会很好地保存选项。
case \'select\':
echo \'<select name="\', $field[\'id\'], \'" id="\', $field[\'id\'], \'">\';
foreach ($field[\'options\'] as $option) {
echo \'<option value="\', $option[\'value\'], \'"\', $meta == $option[\'value\'] ? \' selected="selected"\' : \'\', \'>\', $option[\'name\'], \'</option>\';
}
echo \'</select>\';
break;
以下是我的修改版本,允许显示3个下拉菜单:
case \'champbans\':
echo \'<select name="\', $field[\'id\'], \'_team1ban_1" id="\', $field[\'id\'], \'_team1ban_1">\';
foreach ($field[\'options\'] as $option1) {
echo \'<option value="\', $option1[\'value\'], \'_team1ban_1"\', $meta == $option1[\'value\'] ? \' selected="selected"\' : \'\', \'>\', $option1[\'name\'], \'</option>\';
}
echo \'</select>\';
echo \'<select name="\', $field[\'id\'], \'_team1ban_2" id="\', $field[\'id\'], \'_team1ban_2">\';
foreach ($field[\'options\'] as $option2) {
echo \'<option value="\', $option2[\'value\'], \'_team1ban_2"\', $meta == $option2[\'value\'] ? \' selected="selected"\' : \'\', \'>\', $option2[\'name\'], \'</option>\';
}
echo \'</select>\';
echo \'<select name="\', $field[\'id\'], \'_team1_3" id="\', $field[\'id\'], \'_team1_3">\';
foreach ($field[\'options\'] as $option3) {
echo \'<option value="\', $option3[\'value\'], \'_team1ban_3"\', $meta == $option3[\'value\'] ? \' selected="selected"\' : \'\', \'>\', $option3[\'name\'], \'</option>\';
}
echo \'</select>\';
break;
没有显示任何错误,在花了2个小时查看后,我无法发现错误。非常感谢您的帮助或指导。