在编辑文章时添加 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/