Delay When Your Posts Go to RSS

 In RSS Feeds

Have you ever published a post and then realised there was a huge mistake in the first paragraph? It’s easy enough to fix the error, but it’s too late for all your subscribers – your post has already been published in their RSS feeds.

Delay when your posts are published to RSS and give yourself time to double-check your live posts. Add this snippet to your

function publish_later_on_feed($where) {
global $wpdb;
if ( is_feed() ) {
$time_now = gmdate('Y-m-d H:i:s');
$time_delay = '15'; // integer
$time_span = 'MINUTE'; //MINUTE, HOUR, DAY, WEEK, MONTH, YEAR
$where = " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$time_now') > $time_delay ";
}
return $where;
}
add_filter('posts_where', 'publish_later_on_feed');

You can change the value of $delay to whatever length of time suits you.

Recommended Posts

Leave a Comment

Start typing and press Enter to search