WordPress Wednesdays: Delay RSS Send Out

This WordPress Wednesdays entry is a re-post from Matthew’s old blog as we resurrect them here at GeekRev.

It’s that time of the week again where I give you some sort of hack or tip for your WordPress arsenal. Today I want to hit up the RSS side of things. RSS plays a very important role in the success of your blog. With RSS folks can be sent your posts, comments and more just by subscribing to your blog’s RSS feed.

A very easy hack, that I subscribe to is putting a time buffer between when I post and when my RSS feed is sent out to the world. This gives me a moment to fix any “ahh craps”!

We have all been there, published a post and went “ahhh crap!”, and realized that we¬†misspelled¬†a few words or forgot to add this or need to delete this. Well, after you hit publish, your RSS feed is updated and even though you go back and fix that error, RSS already has it and it’s around the world and in someone’s reader by now.

Easily remedied!

Below is the code that you will need to add to your functions.php file. MAKE SURE YOU BACK THIS FILE UP before you make any changes. The functions.php can be found in your theme folder under this path – /wp-content/themes/name of your theme here.

Once you have backed this up, add the following code to it. It doesn’t make a difference where the code goes.
[PHP]
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’);
[/PHP]

The above code will wait 5 minutes after the post is published to send it off to the land of RSS. This gives you ample time to fix any last second “ah craps” before resting easy until the next time.

Well that is it for today, hope this helps someone out there!

4 Replies to “WordPress Wednesdays: Delay RSS Send Out”

Leave a Reply

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