I would like to know that how fetch_feed() works extactly?

From the Codex:

fetch_feed() caches results for 12 hours by default.

That means if I use fetch_feed( 'howtogeek.com' ), it reads the RSS feeds from howtogeek at first, it will save the result for 12 hours.

Otherwise what is the meaning of caches results for 12 hours by default.?

  • 2
    What other meaning could that be? I don't really get your question.
    – fuxia
    Commented May 23, 2016 at 18:01
  • The answer is yes else what do you want to know ?
    – Sumit
    Commented May 23, 2016 at 18:06
  • @toscho I think the question is when it is read/cached (based on first visit or at a specific time maybe...)
    – Sven
    Commented May 23, 2016 at 18:07
  • If you meant the "by default", then it's 12 hours unless you return a different value from filter wp_feed_cache_transient_lifetime.
    – Rup
    Commented May 23, 2016 at 18:12

1 Answer 1


1 fetch_feed will get the feed and store it, along with the time it was fetched.

2 Every time the page with the feed is generated the time will be checked. If it is more than twelve hours ago, the feed will be reloaded. Note that this may interfere with caching plugins, who will bypass the normal page generation. Also, if the site is visited very little, the first visitor after twelve hours may still see the old feed, because WP is not particularly good at cron jobs.

3 If you don't specify another time twelve hours is the caching time for the feed. You may set up any other interval with this snipppet:

function feed_interval( $seconds ) {
  return 3600; // caching time in seconds
add_filter( 'wp_feed_cache_transient_lifetime' , 'feed_interval' );
  • "WP is not particularly good at cron jobs" - does WP manage the cache? It pretty much delegates everything else here to SimplePie, which I assume uses some standard PHP cache under the covers?
    – Rup
    Commented May 24, 2016 at 8:59
  • Without claiming too much knowledge on this one: WP has its own cron process, which delegates a lot, but because it has to run on all sorts of systems it can't get all the details right. My own experience is that WP needs visits to the site to keep all processes going. If there have been no visits all night an early morning scheduled post is easily missed, for instance. This may also mean missing a scheduled refresh of the cache.
    – cjbj
    Commented May 24, 2016 at 10:23

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.