Delay When Your Posts Go to RSS

 In All, RSS

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Start typing and press Enter to search

Let's work together

I'd love to work with you! Please fill out my project form to tell me more about your project/work. I reply to all enquiries within 48 hours.

Availability

  • November - Booked
  • December - Booked
  • January - Available

Rates

  • My day rate is £300.
  • I can provide a fixed price for your work.

EN - Header Enquiry Form

  • This form collects your name, email address and telephone number so that I can respond to the enquiry(ies) that you submit via this website. Please check my privacy policy for the full story on how I use, protect and manage your submitted data.