Created
November 27, 2018 21:57
-
-
Save robertuniqid/6615291403ac09369e8abb77df02b18c to your computer and use it in GitHub Desktop.
WordPress Clear oEmbed Cache Automatically on Post Save
This file contains hidden or 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 | |
add_action( 'save_post', function( $post_id ) { | |
if( get_post_type( $post_id ) != WPEP_POST_TYPE_COURSE ) | |
return; | |
global $wpdb; | |
$wpdb->query( 'DELETE FROM `' . $wpdb->postmeta . '` WHERE `meta_key` LIKE "_oembed%" AND post_id = ' . $post_id ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment