I'm using the built-in SimplePie, AKA fetch_feed(), to retrieve a feed, and I want to be able to adjust the cache time from an admin menu. SimplePie itself is well documented, but not so much the WordPress implementation of it.

Any thoughts on the best way to set the cache duration?

2 Answers 2


Cache duration value (defaults to 43200 seconds) is set when feed object is generated and passed through wp_feed_cache_transient_lifetime filter with additional argument being feed URL.

This allows to conveniently filter it both globally and for specific feeds.

See fetch_feed() source for this and other hooks you can use to modify its behavior.

  • 1
    I love it when the only documentation is the source! Yay! <sarcasm />
    – Dan Gayle
    Oct 13, 2010 at 17:42
  • Ha ha. I notice that you asked the same question last year wptavern.com/forum/troubleshooting/… :)
    – Dan Gayle
    Oct 13, 2010 at 21:55
  • Learn and spread the knowledge. :)
    – Rarst
    Oct 14, 2010 at 7:45

To elaborate on Rarst's solutuion. I've been using the following to great success:

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

This sets the feed cache at one hour and should be placed immediately after the feed.php include.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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