WordPress 删除空的 span 标签 [英] WordPress removes empty span tag
问题描述
我使用 WordPress 编辑器,我想在span"标签中显示一个图标,如下所示:
<div class="box-left"><span class="fa fa-search" aria-hidden="true"></span></div><div class="box-right"><h3>一些标题</h3>一些文字<span id="question1-answer"></span>
每当我对视觉"进行更改时,它都会删除跨度"标签,如下所示:
<div class="box-left"></div><div class="box-right"><h3>一些标题</h3>一些文字<span id="question1-answer"></span>
奇怪的是,底部的跨度 (id="question1-answer") 被保留了下来.我错过了什么吗?我已经尝试在标签中设置一个空格 ",在更改visual"中的文本并使用不同的标签后,它将被转换为"(实际空格).
谢谢!
将此代码添加到您的活动主题 functions.php 文件中.
function override_mce_options($initArray) {$opts = '*[*]';$initArray['valid_elements'] = $opts;$initArray['extended_valid_elements'] = $opts;返回 $initArray;}add_filter('tiny_mce_before_init', 'override_mce_options');
I use WordPress-editor and I want to display an icon within a "span"-tag like this:
<div id="question1" class="box-around">
<div class="box-left"><span class="fa fa-search" aria-hidden="true"> </span></div>
<div class="box-right">
<h3>Some Heading</h3>
Some Text
<span id="question1-answer"> </span>
</div>
</div>
Whenever I make a change in "visual", it removes the "span"-tag and looks like this:
<div id="question1" class="box-around">
<div class="box-left"></div>
<div class="box-right">
<h3>Some Heading</h3>
Some Text
<span id="question1-answer"> </span>
</div>
</div>
Oddly enough, the span at the bottom (id="question1-answer") is kept. Am I missing something? I already tried to set a whitespace " " within the tag, which will be converted to a " " (actual whitespace) after changing text in "visual" and used different tags as well.
Thanks!
Add this code in your active theme functions.php file.
function override_mce_options($initArray) {
$opts = '*[*]';
$initArray['valid_elements'] = $opts;
$initArray['extended_valid_elements'] = $opts;
return $initArray;
}
add_filter('tiny_mce_before_init', 'override_mce_options');
这篇关于WordPress 删除空的 span 标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!