How to delay post in RSS Feeds in WordPress

Okay, this is probably one of the ‘damn it happened again!’ situations that we come across in WordPress. So this is how to delay post in RSS feeds in WordPress.

Delay RSS Feeds in WordPress

Quite a few times in your blogging time you must have come across a situation when you have accidentally published an article before it was actually ready.  When this happens we normally unpublish the article or change the date to some future time. But there has been a hack that can help us with this issue and actually delay RSS feeds so that even if we publish an article accidentally, the subscribers wouldn’t get the notification as it gets published.

Just add the following code to the functions.php file.

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
        $device = 'MINUTE'; //MINUTE, HOUR, DAY, WEEK, MONTH, YEAR
        // 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');

What this does is delays your post by 10 seconds so your subscribers will only be notified of your articles after 10 seconds of you hitting the publish button. You can change the delay time according to your requirement.

  • Leave a Reply