Title: delete_comment_meta
Published: April 25, 2014
Last modified: February 24, 2026

---

# delete_comment_meta( int $comment_id, string $meta_key, mixed $meta_value ): bool

## In this article

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

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

Removes metadata matching criteria from a comment.

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

You can match based on the key, or key and value. Removing based on key and value,
will keep from removing duplicate metadata with the same key. It also allows removing
all metadata matching key, if needed.

For historical reasons both the meta key and the meta value are expected to be “
slashed” (slashes escaped) on input.

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

 `$comment_id`intrequired

Comment ID.

`$meta_key`stringrequired

Metadata name.

`$meta_value`mixedoptional

Metadata value. If provided, rows will only be removed that match the value.
 Must
be serializable if non-scalar. Default empty string.

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

 bool True on success, false on failure.

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

    ```php
    function delete_comment_meta( $comment_id, $meta_key, $meta_value = '' ) {
    	return delete_metadata( 'comment', $comment_id, $meta_key, $meta_value );
    }
    ```

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

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

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

Deletes metadata for the specified object.

  |

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

Permanently deletes comments or posts of any type that have held a status of ‘trash’ for the number of days defined in EMPTY_TRASH_DAYS.

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

Marks a comment as Spam.

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

Removes a comment from the Spam.

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

Moves a comment to the Trash

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

Removes a comment from the Trash

  |

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

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

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

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/delete_comment_meta/?output_format=md#comment-content-1492)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/delete_comment_meta/#comment-1492)
 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%2Fdelete_comment_meta%2F%23comment-1492)
    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%2Fdelete_comment_meta%2F%23comment-1492)
 4. **Delete all metadata with the key ‘my_meta_key’ for comment ID 5.**
 5.     ```php
        delete_comment_meta( 5, 'my_meta_key' );
        ```
    
 6. **Delete metadata for ‘my_meta_key’ only where the meta_value is ‘foo’.**
 7.     ```php
        delete_comment_meta( 5, 'my_meta_key', 'foo' );
        ```
    
 8.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fdelete_comment_meta%2F%3Freplytocom%3D1492%23feedback-editor-1492)

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