如何设置WordPress的RSS feed更新频率
- 时间:2020-05-17 12:22:02
- 分类:网络文摘
- 阅读:100 次
每个通过wordpress建立的网站都有一个 RSS feed 链接,利用RSS聚合器或带有RSS订阅功能的浏览器(IE内核)通过该链接就可以订阅到网站的最新文章,比如本站的RSS订阅地址:http://uuxn.com/feed,在该网页的源代码中搜索“updatePeriod”可以看到如下两行代码:
- <sy:updatePeriod>hourly</sy:updatePeriod>
- <sy:updateFrequency>1</sy:updateFrequency>
此代码中“hourly”表示feed更新频率的时间单位是小时,而“1”则表示更新频率的时间。这两行代码的作用就是告诉RSS聚合器说:wordpress默认的feed更新频率为每1小时一次,你按这个频率访问就可以了。但对于大多数个人博客而言,每天发布一篇文章就不错了,显然feed每小时一次的更新频率实在太快了,这会导致网站的feed链接被频繁访问,进而耗费更多的网站流量,加重服务器负担。为了改变这种情况,就需要自行设置RSS feed的更新频率,由于在wordpress后台并没有相关的设置选项,我们可以通过以下代码来解决:
添加如下代码到wordpress主题的functions.php模板文件中:
- add_filter( 'rss_update_period', function() {return 'daily';} );
- add_filter( 'rss_update_frequency', function() {return '3';} );
上述代码表示feed更新频率设定为每3天更新一次,其中第一行代码中的“daily”值表示时间单位是“天”,时间单位可以设置为:'hourly', 'daily', 'weekly', 'monthly', 'yearly',分别代表:小时,天,星期,月,年。第二行代码中的“3”表示更新频率的时间,大家可以根据自己博客文章的更新频率来设定这两个值。
原文:https://www.ludou.org/wordpress-set-rss-update-period.html
想要关闭WordPress的RSS feed可参考:https://www.ludou.org/how-to-remove-feeds-from-wordpress-totally.html
想要实现WordPress的RSS feed静态化可参考:https://www.ludou.org/wordpress-feed-static.html
推荐阅读:How to Clone a Graph in C++/Java using Depth First Search Algori The Unique Morse Code Words Algorithm The Algorithm to Find Anagram Mappings between Two Arrays How to Write More Readable Blog Posts Due.com Review: It Really Is An Easy Way to Keep Track of Your I Twitter Mishaps: The Infamous, The Insensitive, and the Unfunny Standing Out from the Crowd: How to Get Your Content Noticed in How to Leverage Social Media for Events to Achieve Your Goals Grammar-Geeking Tools for Clearer Blog Content Work More Blogging Jobs, Earn More with Bloggerjobs.biz
- 评论列表
-
- 添加评论