WordPress: Adding delay between post and rss

Categories blog

The case here when you have a wordpress website and you’ve made a post and immediately realized that there is an error or some sort of mistake. The default setting here is not forgiving and the RSS feed has been pushed to all your readers. There is a hack to override this and add a custom delay.

Open functions.php on your theme editor

[cc lang=”php”]

function delay_post_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, this refers to minutes for the delay

		$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', 'delay_post_on_feed');

[/cc]

Posting stuff that helped me and so I don’t forget :-)

No Comments

You can say something here...