我如何删除这些
标签
第一个问题在这里 :)
我目前正在 http://ahrengot.com/ 试验我的第一个 WordPress 主题,但是我逐渐了解到 WP 有一种奇怪的行为,即在标记中添加随机换行符。
这是我所拥有的内容的简化:
<br>
<section>...</section>
<br>
<p> </p>
<section>...</section>
<br>
我需要删除每个部分之前和之后的换行符。请注意,这里既有 br 标签,也有 ANDnbsp;。我想我需要正则表达式,但我完全没有这方面的经验,所以如果有人能指出我正确的方向,我将非常感激:)
first question here :)
I'm currently experimenting with my first WordPress theme over at http://ahrengot.com/, but i've come to learn that WP has the odd behaviour of throwing random line breaks into your markup.
This is a simplification of what i have:
<br>
<section>...</section>
<br>
<p> </p>
<section>...</section>
<br>
I need to remove the line breaks before and after each section. Note that there are both br tags and ANDnbsp;'s here. I suppose i need RegEx for this, but I have absolutely no experience with that, so if anyone could point me in the right direction I would be very thankful :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
哪个版本的WP?
当 HTML 视图中的元素后面有额外的空间时,它是否会添加中断?我是 WordPress 用户,完全没有这个问题。我选择了“修复无效嵌套的 XHTML”框。
以下是法典上的一个线程,其中包含建议的补丁:
http: //wordpress.org/support/topic/empty-content-creates-an-extra-ltbrgt
您是从头开始编写主题的吗?如果没有,您可能还需要检查主题函数文件,以确保“wpautop”函数没有被覆盖或使用不同的参数调用。
Which version of WP?
Does it add breaks when there is extra space after your elements in the HTML view? I am a Wordpress user and I don't have this problem at all. I have the "fix invalidly nested XHTML" box selected.
Here is a thread on the codex that has a suggested patch:
http://wordpress.org/support/topic/empty-content-creates-an-extra-ltbrgt
Did you write the theme from scratch? If not you might want also to check your theme functions file to make sure the 'wpautop' function isn't being overridden or called with a different param.
你可以作弊,但它可能会通过“隐藏”中断来破坏其他东西。如果它位于某种包装类中,效果最好。
You can cheat, but it may break other things by "hiding" the breaks. It works best if it's inside some sort of wrapping class.
你可以尝试
位于模板顶部。
You can try
<?php remove_filter ('the_content', 'wpautop'); ?>
at the top of your template.