How To Force Instant RSS Feed Update in WordPress?

Recently a Managed WordPress owner raised a question about how to force an immediate update to RSS feeds in WordPress.

Is there a way to force RSS feed update on my website? My problem is after I have made changes to a blog post? I have noticed that once the content is published, the RSS feed is sent and I can see it in my own RSS reader, but then I cannot update it anyhow, even if I change everything in the post. Frustratingly, the RSS keeps showing the old version, even after I manually update my feed reader.

By default what happens is when you update posts, tags or categories on your website, the content sent via RSS feed remains the same for longer period of time. The reason is default feed update cycle of WordPress is twelve hours.

Solution to this common issue is easy, what you have to do is change the default update cycle of WordPress to a lesser period of time i.e. 30 or 60 seconds. This can easily be done by using following snippet of code:

add_filter('wp_feed_cache_transient_lifetime', create_function('', 'return 60;'));

You simply need to copy and paste this line code into your theme’s function.php file or you can use it on Code Snippet plugin which provides you a better way of implementing new PHP functions on WordPress.

Now what this PHP snippet will do is, it will update your RSS feed in a minute, then you may check the updated feed of your website and remove the code to return back to the default feed cycle of WordPress.

Leaving this code active on your website will utilize more resources. Hence it is better to deactivate the code and use it only when you need it.

Another easy trick that works sometimes – Login to your WordPress admin area Settings -> Reading and change the number in ‘Syndication feeds show the most recent‘ option, this also updates the RSS feed. Once feed is updated, you may change the number back to whatever it was before.

Although this trick works but we still do not recommend this method because first it re-publishes the feed each time you change the number which results in displaying duplicate posts to your feed readers, though newly updated posts are shown on top. Second – this trick works due to a bug in WordPress which off-course will not be there forever.

2 thoughts on “How To Force Instant RSS Feed Update in WordPress?”

  1. Thanks for this.

    I use a WordPress RSS Feed widget to display feeds from numerous website on another and was wondering why new posts were not displaying.

    I added the code to my functions file and all new posts displayed as expected

    Thanks again.

  2. Because create_function is deprecated, it’s better to use an anonymous function or a named function for this purpose. Here’s an updated version of the code using an anonymous function:

    add_filter(‘wp_feed_cache_transient_lifetime’, function () {
    return 60;
    });

    This code achieves the same result but uses a more modern and recommended approach for defining callback functions in WordPress filters.

Leave a Reply

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