WordPress 删除摘录过滤器
我正在尝试删除默认情况下为 the_excerpt(); 放置的周围标签;
我已经尝试过以下...
<?php remove_filter('the_excerpt', 'wpautop'); ?>
<p class='test'><?php the_excerpt(); ?></p>
并且我已经尝试过...
<?php $formatted = remove_all_filters('the_excerpt', the_excerpt()); ?>
<p class='test'><?php echo $formatted ?></p>
我正在寻找生成这个...
<p class='test'>the excerpt text <a href='http://continuereadinglink'>etc.</a></p>
但是 WordPress 输出了这个...
<p class='test'></p>
<p class='default-align'>the excerpt text <a href='http://continuereadinglink'>etc.</a></p>
我实际上在这里找到了解决方法 http://aaronrussell.co.uk/legacy/improving-wordpress-the_excerpt/,但它基本上涉及替换这excerpt 函数,我宁愿避免这种情况,因为我只想去掉过滤器。
I'm trying to strip the surrounding tags that are put out by default for the_excerpt();
I've tried the following...
<?php remove_filter('the_excerpt', 'wpautop'); ?>
<p class='test'><?php the_excerpt(); ?></p>
and I've tried...
<?php $formatted = remove_all_filters('the_excerpt', the_excerpt()); ?>
<p class='test'><?php echo $formatted ?></p>
I'm looking to produce this...
<p class='test'>the excerpt text <a href='http://continuereadinglink'>etc.</a></p>
But instead WordPress outputs this...
<p class='test'></p>
<p class='default-align'>the excerpt text <a href='http://continuereadinglink'>etc.</a></p>
I have actually found a workaround here http://aaronrussell.co.uk/legacy/improving-wordpress-the_excerpt/, but it basically involves replacing the excerpt function, and I would rather avoid this since I just want to strip the filters out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HTML 段落标签不支持嵌套结构。尝试用块元素(例如 DIV
)包围摘录
您可以尝试此选项:
HTML paragraph tags don't support nested structure. Try to surround the excerpt with block elements such as DIV
You may try this option: