Skip to content

Instantly share code, notes, and snippets.

@cliffordp
Last active June 24, 2016 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cliffordp/e331b28d0d4d3b042fc7daf714256796 to your computer and use it in GitHub Desktop.
Save cliffordp/e331b28d0d4d3b042fc7daf714256796 to your computer and use it in GitHub Desktop.
Wipe all stored oEmbeds from WordPress database
<?php
/**
*
* Warning: If you do NOT follow step #3, your site will be significantly less efficient than it should be!
*
* 1. add this code to your theme's functions.php file
* 2. load a page on the front-end of your site (e.g. the home page)
* 3. comment out or delete this code from your theme's functions.php file
* 4. check to see if previously incorrect oEmbeds are now fixed (i.e. visit a page that had one and see if the oEmbed is now displaying correctly)
*
*
* From https://gist.github.com/cliffordp/e331b28d0d4d3b042fc7daf714256796
*
*/
function wipe_oembed_postmeta() {
global $wpdb;
$wpdb->query( "
DELETE
FROM $wpdb->postmeta
WHERE meta_key LIKE '_oembed_%'
" );
}
add_action( 'init', 'wipe_oembed_postmeta' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment