Delaying your WordPress RSS Feed

I can’t tell you how many times I have written an article, hit publish, then realized that I made some mistakes.  It doesn’t matter how much I proofread a post, it happens all the time.  With that, our readers get these articles delivered to them through my feed.  Wouldn’t it be nice if I could delay the feed a bit, just in case I have to make a change? Well, you can… and this is how.

The code below will delay your feed for 30 minutes.  You can change the time it takes by editing the integer and designating the time in minutes, hours, days, etc.

1. edit your theme’s functions.php file
2. paste the following code between the <?php and the ?>

//--------------------------------------------------------------------------
// Start Delay 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 = '30'; // 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');
// --------------------------------------------------------------------------
// End Delay Feed
// --------------------------------------------------------------------------

Note: These functions are not of my own creation, simply things I have found along the way.  If you are the author of this function, please let me know so I can properly credit you with your work!

About Joe D

I have always had a passion for everything computing. In early 2000, I decided to take my passion to the web. Thus, C.O.D. was born. Through the years we have made many great friends at C.O.D. and hope to continue our journey for years to come.

Check Also

Manage Multiple WordPress Sites with InfiniteWP

Running your website, or websites, on WordPress is an easy choice as the flexibility the …

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.