Delay your feed updates

You can set the feed update time with a simple function. The only need you have to edit your theme’s functions.php. Let’s Begin.

Here is the code;

// delay feed update
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');

With this code update will wait for 5 minutes. You can chnge this time period. Just change $wait value for this.
That’s All. Have a nice day.


Related posts:

If you enjoyed this post, make sure you subscribe to my RSS Feed
Highslide for Wordpress Plugin