If you've made changes to your oEmbed providers or handlers, you might need to refresh your oEmbed cache to reflect the new changes. This scenario may also apply if an oEmbed provider has changed things around on their end.
In this article, we'll show you how to use WP-CLI to manage your WordPress site's oEmbed cache.
How To Clear Your oEmbed Cache
To refresh your oEmbed cache for all posts, simply navigate to your WordPress site's root directory and enter use the following command:
pagely-wp embed cache clear
Similarly, if you want to only clear the oEmbed cache for a single WordPress post, simply add the post ID to the command like so:
pagely-wp embed cache clear 123
How To Manually Build Your oEmbed Cache
If you want to test out how the oEmbed cache will impact your embedded content, you can manually trigger the oEmbed cache to build on a single post. To do so, navigate to your WordPress site's root directory and run the following command, replacing 123 with your post ID:
pagely-wp embed cache trigger 123
Viewing Your WordPress Site's oEmbed Configuration
Inside WordPress, link embedding is handled using 2 different methods: handlers and providers.
The best way to understand the difference is that handlers control how non-oEmbed links are embedded, and providers control how oEmbed-supported links are embedded.
Because of these two different scenarios, you'll likely need to list them differently when delving into your site's oEmbed configuration.
Listing All oEmbed Providers
To get a list of all providers within your WordPress site, you can run the following WP-CLI command from within your site's root directory:
pagely-wp embed provider list
Listing All Embed Handlers (Non-oEmbed Links)
To see a list of the different handlers that are running on your WordPress site to embed links that do not use oEmbed, you can run the following command from your WordPress site's root directory:
pagely-wp embed handler list