You want to delay posts from appearing immediately in your WordPress RSS feed mainly for two reasons. First, this extra time is often useful to catch and fix an error in your title or article. Second, by delaying a post in the RSS feed, you can give search engines enough time to crawl and index your content first. For that matter, I would recommend a delay time of about 10 minutes.
Below is the code to delay posts from appearing immediately in WordPress RSS feed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//* Delay posts from appearing immediately in WordPress RSS feed | |
add_filter('posts_where', 'customprefix_delay_rss_feed'); | |
function customprefix_delay_rss_feed($where) { | |
global $wpdb; | |
if ( is_feed() ) { | |
$now = gmdate('Y-m-d H:i:s'); // Timestamp in WordPress format | |
$wait = '10'; // Integer | |
$device = 'MINUTE'; // MINUTE, HOUR, DAY, WEEK, MONTH, YEAR | |
$where.= " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$now') > $wait "; // Add SQL syntax to default $where | |
} | |
return $where; | |
} |
Alternatively, you can download, install and set up Feed Delay from the WordPress Plugin Repository.