WordPress wpautop 问题 [英] WordPress wpautop issue

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

问题描述

我已经通过给定的代码禁用了 wpautop:

I have disabled wpautop through the given code:

remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );

此功能有效.但我的实际问题是,它删除了我在内容中手动使用的自定义p"标签.

This function works. But my actual problem is that, it removes custom "p" tags that I have manually used in the content.

所以问题是,当我不使用上面给定的代码时,会自动出现 p 标签破坏我的网站,当我禁用它们时,自定义 p标签也被禁用.

So the problem is that when I don't use the above given code, there are automatic p tags that destroy my website and when I disable them, custom p tags are also disabled.

推荐答案

这是我刚刚通过实验发现的修复/变通方法.给

元素一个属性(

).它甚至不必具有实际价值.WordPress 似乎认为,如果它有一个属性,就值得保留.此外,该属性甚至不必是实际的 HTML 属性.例如,

似乎工作得很好.我并不是说我一定建议这样做,但值得一提.

Here's a fix/work-around I just found through experimentation. Give the <p> element an attribute (<p class>). It doesn't even have to have an actual value. WordPress seems to think that if it has an attribute, it's worth keeping. Furthermore, the attribute doesn't even have to be an actual HTML attribute. For example, <p data-please-work> seems to work just fine. I'm not saying I necessarily recommend doing that, but it's worth mentioning.

实际上我刚刚自己发现了这个问题,并且正在寻找解决方法使我想到了这个问题.这是一个非常令人恼火的情况,我不明白为什么会这样.您可能会认为禁用它只会阻止 WordPress 添加自己的 <p> 元素——但事实并非如此.似乎它试图阻止

元素,周期——甚至是你的.

I actually discovered this problem myself just now, and searching for a fix lead me to this question. It's a very exasperating situation, and I don't understand why it works like that. You would think that disabling it would simply prevent WordPress from adding its own <p> elements—but no. It seems like it tries to prevent <p> elements, period—even yours.

如果其他人有其他方法来处理这个问题,我很想知道.不过,了解 Silver 的提示似乎很有帮助.

If someone else has another way to go about dealing with this, I'd love to know. Silver's tips seem helpful to know though.

这篇关于WordPress wpautop 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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