Title: WP_Embed::delete_oembed_caches
Published: April 25, 2014
Last modified: April 28, 2025

---

# WP_Embed::delete_oembed_caches( int $post_id )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_embed/delete_oembed_caches/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/classes/wp_embed/delete_oembed_caches/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_embed/delete_oembed_caches/?output_format=md#related)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_embed/delete_oembed_caches/?output_format=md#wp--skip-link--target)

Deletes all oEmbed caches. Unused by core as of 4.0.0.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_embed/delete_oembed_caches/?output_format=md#parameters)󠁿

 `$post_id`intrequired

Post ID to delete the caches for.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_embed/delete_oembed_caches/?output_format=md#source)󠁿

    ```php
    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 );
    		}
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-embed.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-embed.php#L386)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-embed.php#L386-L397)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_embed/delete_oembed_caches/?output_format=md#related)󠁿

| Uses | Description | 
| [get_post_custom_keys()](https://developer.wordpress.org/reference/functions/get_post_custom_keys/)`wp-includes/post.php` |

Retrieves meta field names for a post.

  | 
| [delete_post_meta()](https://developer.wordpress.org/reference/functions/delete_post_meta/)`wp-includes/post.php` |

Deletes a post meta field for the given post ID.

  |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_embed%2Fdelete_oembed_caches%2F)
before being able to contribute a note or feedback.