Title: clean_comment_cache
Published: April 25, 2014
Last modified: August 20, 2026

---

# clean_comment_cache( int|array $ids )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/clean_comment_cache/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/clean_comment_cache/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/clean_comment_cache/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/clean_comment_cache/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/clean_comment_cache/?output_format=md#changelog)

Removes a comment from the object cache.

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

 `$ids`int|arrayrequired

Comment ID or an array of comment IDs to remove from cache.

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

    ```php
    function clean_comment_cache( $ids ) {
    	$comment_ids = (array) $ids;
    	wp_cache_delete_multiple( $comment_ids, 'comment' );
    	foreach ( $comment_ids as $id ) {
    		/**
    		 * Fires immediately after a comment has been removed from the object cache.
    		 *
    		 * @since 4.5.0
    		 *
    		 * @param int $id Comment ID.
    		 */
    		do_action( 'clean_comment_cache', $id );
    	}

    	wp_cache_set_comments_last_changed();
    }
    ```

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

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/clean_comment_cache/?output_format=md#hooks)󠁿

 [do_action( ‘clean_comment_cache’, int $id )](https://developer.wordpress.org/reference/hooks/clean_comment_cache/)

Fires immediately after a comment has been removed from the object cache.

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

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

Deletes multiple values from the cache in one call.

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

Sets the last changed time for the ‘comment’ cache group.

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

Calls the callback functions that have been added to an action hook.

  |

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

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

Updates the comment type for a batch of comments.

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

Erases personal data associated with an email address from the comments table.

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

Restores comments for a post from the Trash.

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

Moves comments for a post to the Trash.

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

Sets the status of a comment.

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

Updates an existing comment in the database.

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

Inserts a comment into the database.

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

Trashes or deletes a comment.

  |

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

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

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

## User Contributed Notes

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