WordPress Snippets at WPcustoms

Delay RSS feed publishing of new posts

This code adds a 10 minutes delay of new posts appearing in your RSS feed stream. I’m not really sure where this makes sense – maby you can leave a comment if you got some use for this.


/**
 * Snippet Name: Delay RSS feed publishing of new posts
 * Snippet URL: http://www.wpcustoms.net/snippets/delay-rss-feed-publishing-new-posts/
 */
 function wpc_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';
        $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', 'wpc_publish_later_on_feed');