get_comment_text

Retrieve the text of the current comment.

Description

(string) get_comment_text( (int) $comment_ID = 0, (array) $args = array() ); 

Returns (string)

The comment content.

Parameters (2)

0. $comment_id (int)
WP_Comment or ID of the comment for which to get the text. Default current comment.
1. $args — Optional. (array) => array()
An array of arguments. Default empty.

Usage

  1. if ( !function_exists( 'get_comment_text' ) ) { 
  2. require_once ABSPATH . WPINC . '/comment-template.php'; 
  3.  
  4. // WP_Comment or ID of the comment for which to get the text. 
  5. // Default current comment. 
  6. $comment_id = -1; 
  7.  
  8. // Optional. An array of arguments. Default empty. 
  9. $args = array(); 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = get_comment_text($comment_id, $args); 
  13.  

Defined (1)

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

/wp-includes/comment-template.php  
  1. function get_comment_text( $comment_ID = 0, $args = array() ) { 
  2. $comment = get_comment( $comment_ID ); 
  3.  
  4. /** 
  5. * Filters the text of a comment. 
  6. * @since 1.5.0 
  7. * @see Walker_Comment::comment() 
  8. * @param string $comment_content Text of the comment. 
  9. * @param WP_Comment $comment The comment object. 
  10. * @param array $args An array of arguments. 
  11. */ 
  12. return apply_filters( 'get_comment_text', $comment->comment_content, $comment, $args );