comment_id_fields()WP 2.7.0

Generates 2 hidden fields for the comment form: comment_post_ID and comment_parent. These fields are needed for the correct operation of the comment form.

comment_post_ID — determines which post is being commented on (post ID).
comment_parent — determines the parent comment if this is a reply to another comment. Introduced in version 2.7.

comment_id_fields() should be used inside the html tag <form>.

No Hooks.

Returns

null. Nothing. Outputs the html code of the input fields.

Usage

<?php comment_id_fields(); ?>

Examples

0

#1 Usage example

comment_id_fields()

Display:

<input type='hidden' name='comment_post_ID' value='119' id='comment_post_ID' />
<input type='hidden' name='comment_parent' id='comment_parent' value='251' />

Notes

Changelog

Since 2.7.0 Introduced.
Since 6.2.0 Renamed $post_id to $post and added WP_Post support.

comment_id_fields() code WP 6.9

function comment_id_fields( $post = null ) {
	echo get_comment_id_fields( $post );
}