wp_feed_cache_transient_lifetime

Filters the transient lifetime of the feed cache.

Description

apply_filters( 'wp_feed_cache_transient_lifetime', (int) $lifetime, (string) $filename ); 

Parameters (2)

0. $lifetime (int)
Cache duration in seconds. Default is 43200 seconds (12 hours).
1. $filename (string)
Unique identifier for the cache object.

Usage

To run the hook, copy the example below.
  1. $lifetime = apply_filters( 'wp_feed_cache_transient_lifetime', $lifetime, $filename ); 
  2.  
  3. if ( !empty( $lifetime ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the wp_feed_cache_transient_lifetime callback 
  2. function filter_wp_feed_cache_transient_lifetime( $lifetime, $filename ) { 
  3. // make filter magic happen here... 
  4. return $lifetime
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'wp_feed_cache_transient_lifetime', 'filter_wp_feed_cache_transient_lifetime', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'wp_feed_cache_transient_lifetime', 'filter_wp_feed_cache_transient_lifetime', 10, 2 ); 

Defined (2)

The filter is defined in the following location(s).

/wp-includes/class-wp-feed-cache-transient.php  
  1. $this->lifetime = apply_filters( 'wp_feed_cache_transient_lifetime', $lifetime, $filename); 
/wp-includes/feed.php  
  1. $feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url ) );