Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

2 Answers

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
1  
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
add comment

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
add comment

Your Answer

 
discard

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.