PHP WordPress Textarea小部件保存移动Textarea之外的文本

时间:2015-03-27 07:05:36

标签: php html wordpress textarea

对于php来说还不错,所以我可能会在代码中附加一些额外的数据。 我已根据外部资源的建议在插件部分创建了一个小部件。我在窗口小部件中添加了一个textarea,一切都保存并更新,但文本区域中的信息离开了textarea,并在保存后显示在textarea下面。

由于我的回复不够高,这里有一个指向图像的链接,以显示问题enter image description here

这是我该区域的代码。

<p>
    <label for="<?php echo $this->get_field_id('content'); ?>">
    Text:   <textarea class="widefat" rows="16" cols="16" id="<?php echo $this->get_field_id('content'); ?>" name="<?php echo $this->get_field_name('content'); ?>"/>
    <?php echo esc_attr($content); ?>
    </textarea></label>
</p>

1 个答案:

答案 0 :(得分:1)

您使用self关闭textarea标记,例如:<textarea />。删除它

<p>
    <label for="<?php echo $this->get_field_id('content'); ?>">
    Text:   <textarea class="widefat" rows="16" cols="16" id="<?php echo $this->get_field_id('content'); ?>" name="<?php echo $this->get_field_name('content'); ?>">
    <?php echo esc_attr($content); ?>
    </textarea></label>
</p>