问题
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