wp_feed_cache_transient_lifetime
Filters the transient lifetime of the feed cache.
Description
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.
- $lifetime = apply_filters( 'wp_feed_cache_transient_lifetime', $lifetime, $filename );
- if ( !empty( $lifetime ) ) {
- // everything has led up to this point...
- }
- The following example is for adding a hook callback.
- // define the wp_feed_cache_transient_lifetime callback
- function filter_wp_feed_cache_transient_lifetime( $lifetime, $filename ) {
- // make filter magic happen here...
- return $lifetime;
- };
- // add the filter
- add_filter( 'wp_feed_cache_transient_lifetime', 'filter_wp_feed_cache_transient_lifetime', 10, 2 );
- To remove a hook callback, use the example below.
- // remove the filter
- 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
- $this->lifetime = apply_filters( 'wp_feed_cache_transient_lifetime', $lifetime, $filename);
- /wp-includes/feed.php
- $feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url ) );