get_comment_id_fields

Retrieve hidden input HTML for replying to comments.

Description

(string) get_comment_id_fields( (int) $id = 0 ); 

Returns (string)

Hidden input HTML for replying to comments

Parameters (1)

0. $id — Optional. (int)
Post ID. Default current post ID.

Usage

  1. if ( !function_exists( 'get_comment_id_fields' ) ) { 
  2. require_once ABSPATH . WPINC . '/comment-template.php'; 
  3.  
  4. // Optional. Post ID. Default current post ID. 
  5. $id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_comment_id_fields($id); 
  9.  

Defined (1)

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

/wp-includes/comment-template.php  
  1. function get_comment_id_fields( $id = 0 ) { 
  2. if ( empty( $id ) ) 
  3. $id = get_the_ID(); 
  4.  
  5. $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; 
  6. $result = "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n"; 
  7. $result .= "<input type='hidden' name='comment_parent' id='comment_parent' value='$replytoid' />\n"; 
  8.  
  9. /** 
  10. * Filters the returned comment id fields. 
  11. * @since 3.0.0 
  12. * @param string $result The HTML-formatted hidden id field comment elements. 
  13. * @param int $id The post ID. 
  14. * @param int $replytoid The id of the comment being replied to. 
  15. */ 
  16. return apply_filters( 'comment_id_fields', $result, $id, $replytoid );