【发布时间】:2020-07-13 07:37:57
【问题描述】:
我在 WordPress 中创建了一个自定义小部件,在小部件中我尝试使用 for 循环创建一个选择字段,并在其中显示从 1 到 10 的 10 个数字。
我在 10 号下创建了但它有一个空行。
你能帮我删除那个空行吗?
<label for="<?php echo $this->get_field_id('text'); ?>">
<select width="50" style="width: 50px" class='widefat' id=" <?php $this->get_field_id('timet8t2'); ?>" name="<?php $this->get_field_name('timet8t2'); ?>" type="text">
<?php
for($i=1; $i<11; $i++)
{
echo "<option value=".$i.">"."$i<br>"."</option>";
}
?>
<option name="<?php $this->get_field_name('timet8t2'); ?>"> </option>
</select>
</label>
【问题讨论】:
-
$this->get_field_name('timet8t2')生成的选项没有标签。
标签: php wordpress for-loop select