将以下代码添加到当前主题目录下的 functions.php 文件最后一个 ?> 之前即可。
//RSS Feed 延迟
function publish_later_on_feed($where) {
global $wpdb;
if ( is_feed() ) {
$now = gmdate('Y-m-d H:i:s');
//数据延迟 2 天显示,也就是 feed 只会输出截止到前天的数据,可根据实际需求自行修改
$wait = '2';
$device = 'DAY';
$where .= " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$now') - $wait ";
}
return $where;
}
add_filter('posts_where', 'publish_later_on_feed');
以上内容整理自@张戈博客