我正在尝试使用preg\\u replace从RSS提要中删除6行内容。我已经在线测试了regex,它似乎选择了正确的行。不知何故,这些行没有被删除
add_action(\'the_content_feed\', \'remove_rss_links\');
function remove_rss_links($content) {
return preg_replace(".*appeared first on.*$", "", $content);
}
这是我正在尝试调整的部分提要。
<category><![CDATA[General]]></category>
<guid isPermaLink="false">http://heronsglengolf.com/?p=38</guid>
<description><![CDATA[<p>Below is the directive the committee gave to our architect (Ron Garl) relative to tee renovation: Number “6” tees Must be an option for all holes New “6” tee construction on holes: 1,4,6,8,9, and … <a class="more-link" href="http://heronsglengolf.com/tees/">Continue reading <span class="meta-nav">→</span></a></p>
<p>The post <a rel="nofollow" href="http://foobar.com/tees/">Tees</a> appeared first on <a rel="nofollow" href="http://foobar.com">Golf Course Renovation</a>.</p>
]]></description>
<content:encoded><![CDATA[<p>The post <a rel="nofollow" href="http://foobar.com/tees/">Tees</a> appeared first on <a rel="nofollow" href="http://foobar.com">Golf Course Renovation</a>.</p>
]]></content:encoded>
如果您能帮我更换preg\\u,我们将不胜感激。
最合适的回答,由SO网友:Tom J Nowell 整理而成
正如您在评论中所说:
我只想删除每个帖子2个。对于每一篇文章,我都会在摘录和全文的底部看到一行“文章xxx首先出现在xxx上”。
我很高兴你这么说,正则表达式和XML解析不是最好的处理方法,但事实证明你不需要使用它们。这不是WP功能,而是Yoast SEO功能,可以在以下选项中关闭: