Skip to content

Instantly share code, notes, and snippets.

@jpmarchand
Last active August 22, 2017 09:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpmarchand/bb61016b066211995cba to your computer and use it in GitHub Desktop.
Save jpmarchand/bb61016b066211995cba to your computer and use it in GitHub Desktop.
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