WordPress at Your Fingertips

get_comment_meta() WP 1.0

Retrieve comment meta field for a comment.

1 time — 0.000503 sec (slow) | 50000 times — 0.12 sec (very fast) | PHP 7.0.2, WP 4.4.2

No Hooks.

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 string if a valid but non-existing comment ID is passed.

Usage

get_comment_meta( $comment_id, $key, $single );
$comment_id(int) (required)
Comment ID.
$key(string)
The meta key to retrieve. By default, returns data for all keys.
Default: ''
$single(true|false)
Whether to return a single value. This parameter has no effect if $key is not specified.
Default: false

Changelog

Since 2.9.0 Introduced.

Code of get_comment_meta() WP 5.8.1

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

Metadatas (any)

No comments
    Log In