get_comment_meta

Retrieve comment meta field for a comment.

Description

get_comment_meta( (int) $comment_id, (string) $key = '', (constant) $single = false ); 

Parameters (3)

0. $comment_id (int)
The comment id.
1. $key — Optional. (string) => ''
The meta key to retrieve. By default, returns data for all keys.
2. $single — Optional. (constant) => false
Whether to return a single value.

Usage

  1. if ( !function_exists( 'get_comment_meta' ) ) { 
  2. require_once ABSPATH . WPINC . '/comment.php'; 
  3.  
  4. // The comment id. 
  5. $comment_id = -1; 
  6.  
  7. // Optional. The meta key to retrieve. By default, returns data for all keys. 
  8. $key = ''; 
  9.  
  10. // Whether to return a single value. 
  11. $single = false; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = get_comment_meta($comment_id, $key, $single); 
  15.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/comment.php  
  1. function get_comment_meta($comment_id, $key = '', $single = false) { 
  2. return get_metadata('comment', $comment_id, $key, $single);