在编辑文章时添加 html 代码段,wordpress 可能会自动过滤掉 span标签,那么如何阻止 wordpress 自动过滤到 span 标签,将以下代码放到激活主题的 functions.php 文件中便可以解决这个问题.
//ALLOW SPAN TAG IN WORDPRESS EDITOR
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');
参考
https://blogsneeraj.wordpress.com/2016/02/16/allow-span-tag-in-wordpress-editor/
本文介绍了一种方法,可以在WordPress编辑器中成功使用span标签,通过修改主题的functions.php文件,添加特定代码来实现这一功能,这对于需要精确控制HTML元素的用户来说非常重要。
16

被折叠的 条评论
为什么被折叠?



