Cache oEmbed Results Longer
Keeps embedded content like videos and social posts cached for 30 days instead of re-fetching it from the provider every day.
Opens WPIDE on
Code
// How long embed data stays cached.
$wpide_oembed_ttl = 30 * DAY_IN_SECONDS;
add_filter( 'oembed_ttl', function () use ( $wpide_oembed_ttl ) {
return $wpide_oembed_ttl;
} );
Notes
Changes to an embedded item (a renamed video, for example) take longer to show.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.