WordPress: Changing the fetch_feed Cache Duration

Follow @tristarweb

If you have ever used fetch_feed to bring RSS into your WordPress site, you may have been concerned about the amount of time it takes to update its cache. Fortunately, the solution is simple.

Just add the following code into your themes functions.php file, between the main php tags:

add_filter('wp_feed_cache_transient_lifetime', create_function('$a', 'return 300;'));

Where it says return 300, I am simply telling fetch_feed to refresh it’s cache after 5 minutes (300 seconds).

And that’s it! Quite a useful little filter hook – just thought I’d share it.

About James

Hello there, I'm James. I studied Multimedia Design at university. I'm a designer at heart, though I love developing innovative and exciting solutions to web based products.I now specialise in front end web design and bespoke Wordpress powered websites.

3 Responses to WordPress: Changing the fetch_feed Cache Duration

  1. SEO services says:

    10:34 28/01/2011

    That was a nice and short writeup on cache duration, keep them coming!!..

  2. Fashion Handbags says:

    12:09 28/01/2011

    I enjoyed to c that thinks. Great informative and helpful article.

  3. bnmng says:

    02:27 27/07/2011

    This was very helpful. Thank you.

Leave a Reply

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


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Please wrap all source code with [code][/code] tags.

Follow Tristar on Twitter