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.

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

<?php
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

1 Answer 1

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

 
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.