WP_Embed::delete_oembed_caches()
Delete all oEmbed caches. Unused by core as of 4.0.0.
Method of the class: WP_Embed{}
No Hooks.
Return
null
. Ничего (null).
Usage
global $wp_embed; $wp_embed->delete_oembed_caches( $post_id );
- $post_id(int) (required)
- Post ID to delete the caches for.
Examples
#1 Example of removing the oEmbed cache for a specified post
$post_id = 8045; // see the meta-fields before deletion print_r( get_post_meta( $post_id ) ); // delete $GLOBALS['wp_embed']->delete_oembed_caches( $post_id ); // see the meta-fields after deletion print_r( get_post_meta( $post_id ) );
WP_Embed::delete_oembed_caches() WP Embed::delete oembed caches code WP 6.3
public function delete_oembed_caches( $post_id ) { $post_metas = get_post_custom_keys( $post_id ); if ( empty( $post_metas ) ) { return; } foreach ( $post_metas as $post_meta_key ) { if ( str_starts_with( $post_meta_key, '_oembed_' ) ) { delete_post_meta( $post_id, $post_meta_key ); } } }