Search
Close this search box.

Publish Posts to RSS At a Later Time

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.
Table of Contents

Sponsored Ad

If you purchase through a link on our site, we may earn a commission.

There are plenty of ways to use RSS in WordPress.

This hack delays posting to the RSS feeds for 10 minutes (you can customize the duration in the code).

This can be useful as it gives you some leeway to re-read the live post and make any minor changes before it goes live in your RSS feed.

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.

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

// https://dev.mysql.com/doc/refman/8.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');
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.

Sponsored Ad

If you purchase through a link on our site, we may earn a commission.

All suggestions are anonymous.

More from our blog...

Post a Comment

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.

Stay updated with WP Mayor's newsletter showcase every week

Stay on top of every new WordPress innovation and latest launches. Receive all our fresh product reviews and expert guides directly in your inbox.

Hosting Survey 2024

Are you happy with your hosting provider or are you over-paying for too little? Have your say below!

"*" indicates required fields

What's the main reason you picked this host?*
How happy are you with your host?*

OPTIONAL: If you'd like to receive the results of this survey, please enter your details below.