Skip to content

Instantly share code, notes, and snippets.

@robertuniqid
Created November 27, 2018 21:57
Show Gist options
  • Save robertuniqid/6615291403ac09369e8abb77df02b18c to your computer and use it in GitHub Desktop.
Save robertuniqid/6615291403ac09369e8abb77df02b18c to your computer and use it in GitHub Desktop.
WordPress Clear oEmbed Cache Automatically on Post Save
<?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