Delay When Your Posts Go to RSS

 In RSS Feeds

Have you ever published a post and then realised there was a huge mistake in the first paragraph? It’s easy enough to fix the error, but it’s too late for all your subscribers – your post has already been published in their RSS feeds.

Delay when your posts are published to RSS and give yourself time to double-check your live posts.

function ns_publish_later_on_feed($where) {

 global $wpdb;

 if ( is_feed() ) {
  $time_now = gmdate('Y-m-d H:i:s');
  $time_delay = '15'; // integer
  $time_span = 'MINUTE'; //MINUTE, HOUR, DAY, WEEK, MONTH, YEAR
  $where = " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$time_now') > $time_delay ";
 }

 return $where;
}
add_filter('posts_where', 'ns_publish_later_on_feed');

Put the above code snippet in your theme’s functions.php file and then you will have your feed published 5 minutes later. You can adjust the time you just need to adjust the variable $time_delay to the respective minutes

 

Read more about WordPress Feed here.

Thank you for seeing my tutorial and fell free to share and comment 🙂 . Do you have a code snippet and you want to see it publish on my site ? I will be more than happy to do it please send me a message (here)

Recommended Posts

Leave a Comment

Start typing and press Enter to search