How to Delay Posts From Appearing in WordPress RSS Feed485

How to Delay Posts From Appearing in WordPress RSS Feed
Author: InfoBeep - September 17, 2017 | subject to copyright

Why delay feed in WordPress?

RSS feeds are used by content scraping websites all over the globe and they copy it as soon as you upload a post. Whenever you upload a post, it goes live and is distributed to your RSS feed subscribers and email subscribers. If your post is fine then that won’t be an issue but if it has a mistake it may harm your reputation. Delay feed in WordPress gives little time to catch an error on a live stat and fix it.

Delaying posts in WordPress RSS feed

In order to delay posts in WordPress RSS feed add the code below to your themes functions.php file or in a site-specific plugin.

function publish_later_on_feed($where) {
global $wpdb;
if ( is_feed() ) {
// timestamp in WP-format
$now = gmdate('Y-m-d H:i:s');
// value for wait; + device
$wait = '10'; // integer
// add SQL-sytax to default $where
$where .= " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$now') > $wait ";
return $where;
add_filter('posts_where', 'publish_later_on_feed');

(note:  Here we have used 10 minutes of delay or $wait)
The above code checks if a WordPress feed is requested. After that, it checks for the time you want to delay between the post’s original date and the current time.