我试图在主题中添加一些选项,并添加了一个所见即所得的textarea,该textarea的值将进入选项表(wp-options)。
所以这是我使用的代码:
$settings = array(
'textarea_name' => 'options[content]',
'quicktags' => true,
'tinymce'=> true,
);
wp_editor( get_option('content','default_value'), 'content', $settings );
这项工作很好,但是显然从内容中删除了所有
<p>
标记,我绝对不知道为什么。例如,当我写这样的东西时:
Level 1 title
Level 2 title
a paragraph
another paragraph
这是发送到数据库的称为“内容”的代码:
<h1>Level 1 title</h1>
<h2>Level 2 title</h2>
a paragraph another paragraph
代替这个:
<h1>Level 1 title</h1>
<h2>Level 2 title</h2>
<p>a paragraph</p>
<p>another paragraph</p>
您是否知道我可以使用所有标签获得不变的价值?
ps:当我在文本侧手动添加
<p>
标记时,它会一直起作用,直到我回到视觉侧并重新保存。感谢您的帮助
最佳答案
在内容上使用wpautop
功能可在段落周围添加<p>
标记。
wp_editor( wpautop(get_option('content','default_value')), 'content', $settings );