Title: wp_cache_delete
Published: April 25, 2014
Last modified: May 20, 2026

---

# wp_cache_delete( int|string $key, string $group = '' ): bool

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_cache_delete/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/wp_cache_delete/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_cache_delete/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_cache_delete/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_cache_delete/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_cache_delete/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_cache_delete/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_cache_delete/?output_format=md#user-contributed-notes)

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

Removes the cache contents matching key and group.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_cache_delete/?output_format=md#description)󠁿

### 󠀁[See also](https://developer.wordpress.org/reference/functions/wp_cache_delete/?output_format=md#see-also)󠁿

 * [WP_Object_Cache::delete()](https://developer.wordpress.org/reference/classes/WP_Object_Cache/delete/)

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

 `$key`int|stringrequired

What the contents in the cache are called.

`$group`stringoptional

Where the cache contents are grouped.

Default:`''`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_cache_delete/?output_format=md#return)󠁿

 bool True on successful removal, false on failure.

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

    ```php
    function wp_cache_delete( $key, $group = '' ) {
    	global $wp_object_cache;

    	return $wp_object_cache->delete( $key, $group );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/cache.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/cache.php#L190)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/cache.php#L190-L194)

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

| Uses | Description | 
| [WP_Object_Cache::delete()](https://developer.wordpress.org/reference/classes/wp_object_cache/delete/)`wp-includes/class-wp-object-cache.php` |

Removes the contents of the cache key in the group.

  |

| Used by | Description | 
| [WP_AI_Client_Cache::delete()](https://developer.wordpress.org/reference/classes/wp_ai_client_cache/delete/)`wp-includes/ai-client/adapters/class-wp-ai-client-cache.php` |

Delete an item from the cache by its unique key.

  | 
| [WP_Textdomain_Registry::invalidate_mo_files_cache()](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/invalidate_mo_files_cache/)`wp-includes/class-wp-textdomain-registry.php` |

Invalidate the cache for .mo files.

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

Sets the autoload values for multiple options in the database.

  | 
| [wp_clean_theme_json_cache()](https://developer.wordpress.org/reference/functions/wp_clean_theme_json_cache/)`wp-includes/global-styles-and-settings.php` |

Cleans the caches under the theme_json group.

  | 
| [populate_network_meta()](https://developer.wordpress.org/reference/functions/populate_network_meta/)`wp-admin/includes/schema.php` |

Creates WordPress network meta and sets the default values.

  | 
| [populate_site_meta()](https://developer.wordpress.org/reference/functions/populate_site_meta/)`wp-admin/includes/schema.php` |

Creates WordPress site meta and sets the default values.

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

Cleans the caches for a taxonomy.

  | 
| [clean_site_details_cache()](https://developer.wordpress.org/reference/functions/clean_site_details_cache/)`wp-includes/ms-blogs.php` |

Cleans the site details cache for a site.

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

Removes a network option by name.

  | 
| [wp_clean_plugins_cache()](https://developer.wordpress.org/reference/functions/wp_clean_plugins_cache/)`wp-admin/includes/plugin.php` |

Clears the plugins cache used by [get_plugins()](https://developer.wordpress.org/reference/functions/get_plugins/) and by default, the plugin updates cache.

  | 
| [update_core()](https://developer.wordpress.org/reference/functions/update_core/)`wp-admin/includes/update-core.php` |

Upgrades the core of WordPress.

  | 
| [delete_get_calendar_cache()](https://developer.wordpress.org/reference/functions/delete_get_calendar_cache/)`wp-includes/general-template.php` |

Purges the cached results of get_calendar.

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

Remove user meta data.

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

Update metadata of user.

  | 
| [WP_Theme::cache_delete()](https://developer.wordpress.org/reference/classes/wp_theme/cache_delete/)`wp-includes/class-wp-theme.php` |

Clears the cache for the theme.

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

Creates term and taxonomy relationships.

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

Removes term(s) associated with a given object.

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

Deletes a site transient.

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

Updates the value of an option that was already added.

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

Removes an option by name. Prevents removal of protected WordPress options.

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

Deletes a transient.

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

Cleans all user caches.

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

Will clean the post in the cache.

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

Will clean the attachment in the cache.

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

Hook for managing future post transitions to published.

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

Upgrades the revisions author, adds the current post as a revision and sets the revisions version to 1.

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

Deletes the bookmark cache.

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

Adds a user to a blog, along with specifying the user’s role.

  | 
| [clean_blog_cache()](https://developer.wordpress.org/reference/functions/clean_blog_cache/)`wp-includes/ms-site.php` |

Clean the blog cache

  | 
| [get_blog_details()](https://developer.wordpress.org/reference/functions/get_blog_details/)`wp-includes/ms-blogs.php` |

Retrieves the details for a blog from the blogs table and blog options.

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

Updates the comment count for the post.

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

Updates metadata by meta ID.

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

Deletes metadata by meta ID.

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

Adds metadata for the specified object.

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

Updates metadata for the specified object. If no value already exists for the specified object ID and metadata key, the metadata will be added.

  |

[Show 30 more](https://developer.wordpress.org/reference/functions/wp_cache_delete/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_cache_delete/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_cache_delete/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.0.0](https://developer.wordpress.org/reference/since/2.0.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_cache_delete/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/wp_cache_delete/?output_format=md#comment-content-7271)
 2.   [Hyppolite T.](https://profiles.wordpress.org/hyppolitak/)  [  2 years ago  ](https://developer.wordpress.org/reference/functions/wp_cache_delete/#comment-7271)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_cache_delete%2F%23comment-7271)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_cache_delete%2F%23comment-7271)
 4. Let’s say before making an SQL request to retrieve all the data rows of a table
    in your database, you check for a cache and, if there isn’t one, set one.
 5.     ```php
        function wpdocs_all_rows_getter() {
        	global $wpdb;
        	$table_name = $wpdb->prefix . 'wpdocs_table';
    
        	$cache_key = 'wpdocs_cache_key';
        	$results   = wp_cache_get( $cache_key );
    
        	if ( ! $results ) {
        		$results = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM %s', $table_name ) );
        		// Set the cache.
        		wp_cache_set( $cache_key, $results, 'wpdocs_cache_group', 3600 );
        	}
    
        	return $results;
        }
        ```
    
 6. If you later delete a single row from the table, you’ll also have to delete the
    cache you set earlier to ensure data consistency.
 7.     ```php
        function wpdocs_single_row_deleter( $id ) {
        	global $wpdb;
        	$table_name = $wpdb->prefix . 'my_custom_table';
    
        	$rows_deleted = $wpdb->delete( $table_name, array( 'id' => $id ) );
    
        	if ( 0 < $rows_deleted ) {
        		$result = true;
        		// Clear the cache.
        		wp_cache_delete( 'wpdocs_cache_key', 'wpdocs_cache_group' );
        	} else {
        		$result = false;
        	}
    
        	return $result;
        }
        ```
    
 8.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_cache_delete%2F%3Freplytocom%3D7271%23feedback-editor-7271)

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