如何阻止编辑器剥离<p>
标记和“空( ;)”页面上的div?
既然@scribu要求这里提供一个示例代码,那么它就是:
输入:
<p>text</p>
<div> </div>
输出:text
如何阻止编辑器剥离<p>
标记和“空( ;)”页面上的div?
既然@scribu要求这里提供一个示例代码,那么它就是:
输入:
<p>text</p>
<div> </div>
输出:text
我和TinyMCE Advanced有问题。我为此挣扎了一段时间。最终发现了一个简单的解决方案-使用短代码!
将此代码放入函数中。php,然后在希望显示br标记的任何位置输入[br]。
add_shortcode("br", "br_tag");
function br_tag(){
return("<br/>");
}
1) 尝试几个不同的插件,它们可以禁用格式并阻止WP内置的对额外段落和空白的剥离:http://wordpress.org/extend/plugins/search.php?q=formatting&sort=
2) 您可以使用以下命令欺骗WP添加段落分隔符<b> <b/>
在html编辑器中。这是一个不间断的空间<b>
标签。您将无法在可视化编辑器中看到它,因此请将其添加到htnl编辑器中。这很难看,但它不需要完全禁用格式就可以工作。
3) 也可以在函数中执行此操作。php,然后包装不希望格式化的文本<!-- noformat on -->
和<!-- noformat off -->
标签。
function newautop($text)
{
$newtext = "";
$pos = 0;
$tags = array(\'<!-- noformat on -->\', \'<!-- noformat off -->\');
$status = 0;
while (!(($newpos = strpos($text, $tags[$status], $pos)) === FALSE))
{
$sub = substr($text, $pos, $newpos-$pos);
if ($status)
$newtext .= $sub;
else
$newtext .= convert_chars(wptexturize(wpautop($sub))); //Apply both functions (faster)
$pos = $newpos+strlen($tags[$status]);
$status = $status?0:1;
}
$sub = substr($text, $pos, strlen($text)-$pos);
if ($status)
$newtext .= $sub;
else
$newtext .= convert_chars(wptexturize(wpautop($sub))); //Apply both functions (faster)
//To remove the tags
$newtext = str_replace($tags[0], "", $newtext);
$newtext = str_replace($tags[1], "", $newtext);
return $newtext;
}
function newtexturize($text)
{
return $text;
}
function new_convert_chars($text)
{
return $text;
}
remove_filter(\'the_content\', \'wpautop\');
add_filter(\'the_content\', \'newautop\');
remove_filter(\'the_content\', \'wptexturize\');
add_filter(\'the_content\', \'newtexturize\');
remove_filter(\'the_content\', \'convert_chars\');
add_filter(\'the_content\', \'new_convert_chars\');
我知道这是一个相当古老的论坛。。。在这个问题上,我遇到过很多视觉编辑器在切换标签时剥离标签的问题。。。我简单地点击了以下链接:http://rubayathasan.com/reviews/enabling-line-break-in-wordpress/#comment-1349250
并安装了TinyMCE Advanced。。。一切都很有魅力,我现在有更多的功能可以添加到我的视觉编辑器中。
这是一个较老的问题,但这可能对你或其他人有所帮助:
add_filter(\'wp_insert_post_data\', function ($data, $postarr) {
$data[\'post_content\'] = wpautop($data[\'post_content\']);
return $data;
}, 10, 2);
这将在保存之前添加段落标记。当然,编辑仍然了解如何处理它;)这帮不了你
, 但是你可以问问自己,它们是否有必要,也许你可以用css解决这个问题?只是想帮忙。或者使用黑客(<b> <b/>
) 解释人@markratledge
添加您的functions.php
remove_filter (\'the_content\', \'wpautop\');
remove_filter (\'the_excerpt\', \'wpautop\');
但你必须加上不<p>
和<br/>
手动。这些标记不会保存在数据库中。如果要添加HTML标记,为什么不使用HTML Editor?
有点死尸,但是<p>
标记您可以添加一个类或其他属性。
e、 g。
<p class="nothing-relevant">Foo</p>
我正在尝试向小部件添加富文本编辑器,并使用CKEditor(http://ckeditor.com/download ) 使用简单的工具栏。在我尝试存钱之前,一切都很好。单击“保存”时,文本区域(和文本编辑器)消失,无法保存。删除texteditor允许textarea正常工作和保存。您可以在此处看到小部件代码:http://pastebin.com/C7VbxBSG当然,我添加了wp_register_script 和wp_enqueue_script我使用相同的代码将文本编辑器添加到页面和帖子的文本区