get_comment_id_fields() WordPress Function

The get_comment_id_fields() function is used to generate hidden fields containing the comment ID, author ID, post ID, and parent comment ID. These hidden fields are used when submitting comments to the server.

get_comment_id_fields( int $post_id ) #

Retrieves hidden input HTML for replying to comments.


Parameters

$post_id

(int)(Optional) Post ID. Defaults to the current post ID.


Top ↑

Return

(string) Hidden input HTML for replying to comments.


Top ↑

Source

File: wp-includes/comment-template.php

function get_comment_id_fields( $post_id = 0 ) {
	if ( empty( $post_id ) ) {
		$post_id = get_the_ID();
	}

	$reply_to_id = isset( $_GET['replytocom'] ) ? (int) $_GET['replytocom'] : 0;
	$result      = "<input type='hidden' name='comment_post_ID' value='$post_id' id='comment_post_ID' />\n";
	$result     .= "<input type='hidden' name='comment_parent' id='comment_parent' value='$reply_to_id' />\n";

	/**
	 * Filters the returned comment ID fields.
	 *
	 * @since 3.0.0
	 *
	 * @param string $result      The HTML-formatted hidden ID field comment elements.
	 * @param int    $post_id     The post ID.
	 * @param int    $reply_to_id The ID of the comment being replied to.
	 */
	return apply_filters( 'comment_id_fields', $result, $post_id, $reply_to_id );
}


Top ↑

Changelog

Changelog
VersionDescription
3.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More