Publish Posts to RSS At a Later Time

Written by Jean Galea
Written by Jean Galea
This hack delays posting to the RSS feeds for 10 minutes (you can customise it). This can be useful as it gives you some leeway to re-read the live post and make any minor changes before it goes to the RSS feeds. Using this hack you can also keep content exclusive to your site for a day or a week before pushing it out to your RSS readers.

Partner Sponsors

BionicWP

Full disclosure: If you purchase through a link on our site, we may earn a commission. Learn more.

This hack delays posting to the RSS feeds for 10 minutes (you can customise it). This can be useful as it gives you some leeway to re-read the live post and make any minor changes before it goes to the RSS feeds. Using this hack you can also keep content exclusive to your site for a day or a week before pushing it out to your RSS readers.

[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 = ’10’; // 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]

If you enjoyed this post, make sure to subscribe to WPMayor’s RSS feed.

This article was filed in our archives.
Written by Jean Galea
Jean Galea is an investor, entrepreneur, and blogger. He is the founder of WP Mayor, the plugins WP RSS Aggregator and Spotlight, as well as the Mastermind.fm podcast. His personal blog can be found at jeangalea.com.

In this article

Discover More

New discoveries, every week.
Join thousands of designers, developers, and builders that come to WP Mayor to find the best guides, tools, and services for their next website. One email, once a week.
WP Mayor Newsletter

Claim Your Free Website Tip 👇

Leave your name, email and website URL below to receive one actionable improvement tip tailored for your website within the next 24 hours.

"They identified areas for improvement that we had not previously considered." - Elliot

By providing your information, you'll also be subscribing to our weekly newsletter packed with exclusive content and insights. You can unsubscribe at any time with just one click.

What's missing?