Wordpress - empty p tags

主宰稳场 提交于 2019-12-25 07:21:24

问题


I am getting empty p tags that I cannot remove with jQ, nor can I see them in the source. They are being added by a mobile theme and can only be seen with the browser tool. I dont think jQ is adding them...

http://war-mobile.h2client.com/pillar/residential/?wpmp_switcher=mobile

Under the "We offer, right under the top white div border. I know how to solve the problem, as I did above, ([raw]) but I am curious why this is happening?


回答1:


Add the following to your functions.php file in your theme:

add_filter('the_content', 'remove_empty_p', 20, 1);
function remove_empty_p($content){
$content = force_balance_tags($content);
return preg_replace('#<p>\s*+(<br\s*/*>)?\s*</p>#i', '', $content);
}


来源:https://stackoverflow.com/questions/15472531/wordpress-empty-p-tags

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!