Word Press 优化:解决站点 RSS 请求wordpress.org频率过高
仪表盘错误:
RSS 错误: A feed could not be found at `https://planet.wordpress.org/feed/`; the status code is `429` and content-type is `text/html`
解决办法两个:
- 彻底解决:从主题根本上关闭新闻模块
- 相对解决:控制站点新闻模块请求频率
🚩根本解决方式(精准有效):
方式一:移除WordPress后台默认的官方新闻模块(最推荐)
add_action('wp_dashboard_setup', 'remove_wp_news_dashboard_widget');
function remove_wp_news_dashboard_widget() {
remove_meta_box('dashboard_primary', 'dashboard', 'side');
}
上述代码完全禁用WordPress后台“新闻”模块,从而停止后台向planet.wordpress.org的请求。
方式二:调整后台新闻模块请求频率(次推荐)
add_filter('wp_feed_cache_transient_lifetime', function() {
return 86400; // 缓存24小时
});
该代码使后台新闻RSS请求缓存长达24小时,避免频繁请求。
🚩 推荐最佳做法:
- 推荐优先使用方式一,彻底避免类似频繁请求问题出现。
- 若需要保留新闻模块,采用方式二,大幅降低请求频率。