简体   繁体   English

从wordpress的RSS feed中删除类

[英]Remove a class from RSS feed in wordpress

If someone can help to remove a class from my RSS feed in WordPress, completely I want to remove below code from my RSS feed. 如果有人可以帮助从WordPress的RSS提要中删除类,则完全我想从RSS提要中删除以下代码。

<div class="well"> <a class="btn" href="foo.com">foo</a></div>

If noticed well, there could be done via function. 如果注意到的很好,可以通过函数来​​完成。 If you know the trick please share your solution. 如果您知道诀窍,请分享您的解决方案。

Thanks in advance, Gregory 预先感谢,格雷戈里

Try this 尝试这个

add_filter('the_excerpt_rss', 'remove_sc_rss_feed');

function remove_sc_rss_feed( $content )
{
    global $post;

    // Remove div with class using regex
    $content = preg_replace('#<div class="well">(.*?)</div>#', '', $post->post_content);

    return $content;
}

Note: You might not see the changes immediately. 注意:您可能不会立即看到更改。 Wordpress RSS feeds cache for a few hours. Wordpress RSS feed缓存了几个小时。 I'd suggest installing a caching plugin and not cache the feed. 我建议安装一个缓存插件,而不要缓存提要。 I think this plugin will do it https://wordpress.org/plugins/w3-total-cache/ 我认为这个插件可以做到https://wordpress.org/plugins/w3-total-cache/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM