To achieve this recipe, simply paste the following code into your theme's function.php file. If your theme doesn't have this file, just create it.
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 = '5'; // 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');
The above code will add a 5 minutes delay between your post being published on your blog, and on your rss feed. To change the delay, change the value of the $wait variable, on line 9.
Credits goes to WpEngineer for this awesome recipe!
Leave a Comment