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

---

# get_comment_meta( int $comment_id, string $key = ”, bool $single = false ): mixed

## In this article

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

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

Retrieves comment meta field for a comment.

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

 `$comment_id`intrequired

Comment ID.

`$key`stringoptional

The meta key to retrieve. By default, returns data for all keys.

Default:`''`

`$single`booloptional

Whether to return a single value.
 This parameter has no effect if `$key` is not
specified.

Default:`false`

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

 mixed An array of values if `$single` is false.
 The value of meta data field if`
$single` is true. False for an invalid `$comment_id` (non-numeric, zero, or negative
value). An empty array if a valid but non-existing comment ID is passed and `$single`
is false. An empty string if a valid but non-existing comment ID is passed and `
$single` is true. Note: Non-serialized values are returned as strings:

 * false values are returned as empty strings (`''`)
 * true values are returned as `'1'`
 * numbers are returned as strings Arrays and objects retain their original type.

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

    ```php
    function get_comment_meta( $comment_id, $key = '', $single = false ) {
    	return get_metadata( 'comment', $comment_id, $key, $single );
    }
    ```

[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#L581)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/comment.php#L581-L583)

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

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

Retrieves the value of a metadata field for the specified object type and ID.

  |

| Used by | Description | 
| [WP_Comments_List_Table::handle_row_actions()](https://developer.wordpress.org/reference/classes/wp_comments_list_table/handle_row_actions/)`wp-admin/includes/class-wp-comments-list-table.php` |

Generates and displays row actions links.

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

Removes a comment from the Spam.

  | 
| [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/get_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/get_comment_meta/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/get_comment_meta/?output_format=md#comment-content-1251)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/get_comment_meta/#comment-1251)
 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%2Fget_comment_meta%2F%23comment-1251)
    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%2Fget_comment_meta%2F%23comment-1251)
 4. **Basic Example**
 5.     ```php
        // Return a single meta value with the key 'vote' from a defined comment object.
        $vote = get_comment_meta( $comment->comment_ID, 'vote', true );
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_comment_meta%2F%3Freplytocom%3D1251%23feedback-editor-1251)

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