Schedule your posts for RSS in 5 simple steps

RSS feeds are a great way of getting new content from your favorite site. Instead of hitting reload button every now and then to see if your favorite site has received new content, RSS feeds will help you get the latest information right on time. If you decide to use desktop or mobile application, RSS feeds can get even more useful and once you get your feed going, you’ll probably ask yourself how you managed to have lived without it.

By default, every WordPress website generates the feed automatically and you actually don’t have to setup a thing. It is enough to visit http://www.yourdomain.com/feed to receive necessary information.

Even if you don’t use RSS feeds yourself, you should take care of that if you’re running a website where you publish new content periodically.

Usually, WordPress will post your new article in RSS feed automatically after you hit the publish button. While there’s nothing wrong with it and you actually want your article to appear in the feed as soon as possible, sometimes you might want to schedule that post. In this article, we will show you how to delay an RSS post. Just for an example, if you delay the post for few minutes, it will be just enough for you to make some additional changes before the post is posted in the feed.

Here’s the code that you will need in order to achieve this delay:

  1. Open functions.php file
  2. Rewrite the code word for word… or copy and paste the code, of course:
  3. function scheduled_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', 'scheduled_feed');
  4. Change $device variable into minutes, hours, days and so on
  5. Change $wait variable into number of minutes, hours, days or whatever you have chosen. This is the time your post will wait before it gets automatically published in RSS Feed
  6. Save changes

That’s it. You don’t have to do anything else to schedule your RSS feed. Now that you’re already working with RSS feeds, why wouldn’t you customize your feeds directly on the dashboard and read about thing you care about?

START YOUR OWN BLOG

This guide is an introduction to mastering the art of blogging. It provides easy to follow steps to start, maintain, and grow your blog.

Read the guide

Leave a Reply

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