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

Why is the filter removed after fetching feeds in the following example (from WordPress.org?)

function return_7200( $seconds )
  // change the default feed cache recreation period to 2 hours
  return 7200;

add_filter( 'wp_feed_cache_transient_lifetime' , 'return_7200' );
$feed = fetch_feed( $feed_url );
remove_filter( 'wp_feed_cache_transient_lifetime' , 'return_7200' );
share|improve this question
up vote 1 down vote accepted

The filter is added before the call to fetch_feed, then immediately removed so only that particular feed is given a different feed cache transient lifetime. Any other fetch_feed calls within the lifetime of the request won't have that filter applied, so will be given whatever the default cache transient lifetime value is.

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.