Skip to content

Instantly share code, notes, and snippets.

@jpmarchand

jpmarchand/delay-rss-feed.php Secret

Last active Aug 22, 2017
Embed
What would you like to do?
Delay posts from appearing immediately in WordPress RSS feed. Source: http://wpengineer.com/320/publish-the-feed-later/
<?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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.