I'm using WordPress RSS Widget for one of my site. But found it's a bit lazy, it's not taking latest updates into the feed.

How can I make it quick in loading new updates?


WordPress supports external feeds, and parse the feed using a function named fetch_feed() from SimplePie. RSS widget is one of them using the same function to fetch external feed.

The Codex says:

fetch_feed caches results for 12 hours by default.

So, the feed you are fetching is actually at least 12 hours old. But a good news is there also that, you can modify the duration of the fetching by using a filter: wp_feed_cache_transient_lifetime.

How to use that? Simple. Just paste the following code into your theme's functions.php:

add_filter( 'wp_feed_cache_transient_lifetime', function(){ return 1800; });

we are using the filter to modify the duration. Here we are passing our new duration with 1800 [seconds]. The calculation is: 30 minutes = 30 min. x 60 sec. = 1800 sec.

Using the simple code you can change the duration.


  • 1
    Please do not use create_function(). It is very slow and hard to read. Use either real lambdas or regular named functions. – fuxia Mar 20 '14 at 7:15
  • @toscho: Thanks for the suggestion. I changed it to lambda (it's a new term to me though). Is it correct now? Love to learn more. :) – Mayeenul Islam Mar 20 '14 at 10:32
  • 1
    Lambda would look like this: add_filter( 'wp_feed_cache_transient_lifetime', function(){ return 1800; });. – fuxia Mar 20 '14 at 11:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.