functions.php
文件添加:
/** * 删除文章内<p> <p>空段落 wpautop() */ function remove_empty_p( $content ) { $content = force_balance_tags( $content ); $content = preg_replace( '#<p>\s*+(<br\s*/*>)?\s*</p>#i', '', $content ); $content = preg_replace( '~\s?<p>(\s| )+</p>\s?~', '', $content ); return $content; } add_filter('the_content', 'remove_empty_p', 20, 1);