Skip to content

Instantly share code, notes, and snippets.

@edalis
Last active October 17, 2016 07:30
Show Gist options
  • Save edalis/901cb474c4927777ff7da00d053431e2 to your computer and use it in GitHub Desktop.
Save edalis/901cb474c4927777ff7da00d053431e2 to your computer and use it in GitHub Desktop.
WP: Delay Posts in RSS
// http://www.wpbeginner.com/wp-tutorials/how-to-delay-posts-from-appearing-in-wordpress-rss-feed/
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
// http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_timestampdiff
$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');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment