WordPress Snippets at WPcustoms

Scheduling posts for RSS

This function schedules your RSS posts to be published 5 minutes after you initially published your post. A good snippet to take care of last-minute-changes you just saw after publishing your post.


/**
 * Snippet Name: Scheduling posts for RSS
 * Snippet URL: http://www.wpcustoms.net/snippets/scheduling-posts-for-rss/
 */
 function wpc_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', 'wpc_publish_later_on_feed');