WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 1 down vote accepted

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.

share|improve this answer
I love it when the only documentation is the source! Yay! <sarcasm /> – Dan Gayle Oct 13 '10 at 17:42
Ha ha. I notice that you asked the same question last year wptavern.com/forum/troubleshooting/… :) – Dan Gayle Oct 13 '10 at 21:55
Learn and spread the knowledge. :) – Rarst Oct 14 '10 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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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