嗨,我有这个WordPress站点,我想删除自动插入<ul><li> tag
的不必要的断裂标签,这是我将其插入function.php文件的代码:
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );
add_filter( 'the_content', 'nl2br' );
add_filter( 'the_excerpt', 'nl2br' );
add_filter('the_content', 'remove_empty_p', 20, 1);
function remove_empty_p($content){
$content = force_balance_tags($content);
return preg_replace('#<p>s*+(<brs*/*>)?s*</p>#i', '', $content);
}
NL2BR将在其上破坏_content。但是看来<ul><li>
还插入了一个断裂。
我希望只有<p>
标签会破裂。
我的问题是我将如何防止它在<ul><li>
TAG内添加断裂?
有人可以帮助我吗?
任何帮助都非常感谢。tia
尝试以下代码
add_filter('tiny_mce_before_init', 'override_mce_options');
function remove_empty_p( $content ) {
$content = force_balance_tags( $content );
$content = preg_replace( '#<p>s*+(<brs*/*>)?s*</p>#i', '', $content );
$content = preg_replace( '~s?<p>(s| )+</p>s?~', '', $content );
return $content;
}
add_filter('the_content', 'remove_empty_p', 20, 1);
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );