function clean_post_cache($id) {}

Will clean the post in the cache.
Cleaning means delete from the cache of the post. Will call to clean the term object cache associated with the post ID.


  • int $id: The Post ID in the cache to clean

Defined actions

  • clean_post_cache
    do_action('clean_post_cache', $id);

Source code

function clean_post_cache($id) {

	global $_wp_suspend_cache_invalidation, $wpdb;

	if ( !empty($_wp_suspend_cache_invalidation) )


	$id = (int) $id;

	if ( 0 === $id )


	wp_cache_delete($id, 'posts');

	wp_cache_delete($id, 'post_meta');

	clean_object_term_cache($id, 'post');

	wp_cache_delete( 'wp_get_archives', 'general' );

	do_action('clean_post_cache', $id);

	if ( $children = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d", $id) ) ) {

		foreach ( $children as $cid ) {

			// Loop detection

			if ( $cid == $id )


			clean_post_cache( $cid );



	if ( is_multisite() )

		wp_cache_delete( $wpdb->blogid . '-' . $id, 'global-posts' );



No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: