我试图在我的小部件中加入一个简单的下拉菜单。我从以前的小部件中复制了一个,并试图将我自己的值替换到其中。子菜单显示,但单击“保存”时,它仅保存第一个选择(设计1)。实际上,我回显了小部件上的值和显示的所有选项。
一个简单的小部件下拉菜单是什么样的?至于我的代码,我想我需要把它变成“真的”,并用设计来代替它#
<label for="<?php echo $this->get_field_id(\'fold_design\'); ?>"><?php _e(\'Display style:\'); ?></label>
<select id="<?php echo $this->get_field_id(\'fold_design\'); ?>" name="<?php echo $this->get_field_name(\'fold_design\'); ?>" class="widefat" />
<option <?php selected( \'Design1\', $instance[\'fold_design\'], true ); ?>>Design 1</option>
<option <?php selected( \'Design2\', $instance[\'fold_design\'], true ); ?>>Design 2</option>
<option <?php selected( \'Design3\', $instance[\'fold_design\'], true ); ?>>Design 3</option>
<option <?php selected( \'Design4\', $instance[\'fold_design\'], true ); ?>>Design 4</option>
<option <?php selected( \'Design5\', $instance[\'fold_design\'], true ); ?>>Design 5</option>
<option <?php selected( \'Design6\', $instance[\'fold_design\'], true ); ?>>Design 6</option>
<option <?php selected( \'Design7\', $instance[\'fold_design\'], true ); ?>>Design 7</option>
</select>