Last active
June 24, 2016 17:52
-
-
Save cliffordp/e331b28d0d4d3b042fc7daf714256796 to your computer and use it in GitHub Desktop.
Wipe all stored oEmbeds from WordPress database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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