小赖子的英国生活和资讯

不在RSS显示文章摘要的方法

阅读 桌面完整版

RSS 聚合方便阅读者把所有文章(博客)都放在一起阅读,有优点也有缺点.我在 LEONAX 的博客上看到这篇帖子 http://leonax.net/p/7202/rss-output-title-only-from-now-on/ 后觉得非常有道理.所以就把我的博客站点的FEED ([1], [2], [3]) 也全改成只输出标题和链接.

这样的好处是强制用户到作者原网站上阅读: 一是可以参于评论,二是搜索引擎较友好(保护文章的原创性),三是可以看到RSS里没看到的一些CSS效果,比如这个.

方法很简单, 只要编辑 WORDPRESS 的模板 functions.php 里,在文件最后面加入:

1
2
3
4
5
6
7
8
9
10
11
// https://HelloACM.com
add_filter( 'the_content_feed', 'the_content_feed1' );
add_filter( 'the_excerpt_rss', 'the_excerpt_rss1');
 
function the_excerpt_rss1() {
    return "";
}
 
function the_content_feed1($content) {
    return "";
}
// https://HelloACM.com
add_filter( 'the_content_feed', 'the_content_feed1' );
add_filter( 'the_excerpt_rss', 'the_excerpt_rss1');

function the_excerpt_rss1() {
	return "";
}

function the_content_feed1($content) {
	return "";
}

注意只在博客设置页面里只能有两个选项, 全文输出或者显示摘要. 要做就做彻底点, 简单一点好.Less is More.

英文: https://helloacm.com/how-to-disable-content-output-in-rss-feed-for-wordpress/

强烈推荐

微信公众号: 小赖子的英国生活和资讯 JustYYUK

阅读 桌面完整版
Exit mobile version