Wordpress - 空 p 标签 [英] Wordpress - empty p tags

查看:28
本文介绍了Wordpress - 空 p 标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了无法用 jQ 删除的空 p 标签,也无法在源代码中看到它们.它们是由移动主题添加的,只能使用浏览器工具查看.我不认为 jQ 正在添加它们...

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

在我们提供,就在顶部白色 div 边框下方.我知道如何解决问题,正如我上面所做的那样,([原始])但我很好奇为什么会发生这种情况?

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?

推荐答案

将以下内容添加到主题中的 functions.php 文件中:

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);
}

这篇关于Wordpress - 空 p 标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆