Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Action Reference/comment form


comment_form is a template hook triggered at the bottom of a form rendered by comment_form(), right before the closing </form>.

Functions hooked to this action receive the post ID as parameter.


<?php add_action( 'comment_form', 'function_name' ); ?>

where "function_name" is the name of the function to be called.


 * Displays an extra text area for more comments.
 * @param int $post_id The ID of the post where the comment form was rendered.
function wporg_more_comments( $post_id ) {
	echo '<p class="comment-form-more-comments"><label for="more-comments">' . __( 'More Comments', 'your-theme-text-domain' ) . '</label> <textarea id="more-comments" name="more-comments" cols="45" rows="8" aria-required="true"></textarea></p>';

add_action( 'comment_form', 'wporg_more_comments' );

Source File

The comment_form hook is found in wp-includes/comment-template.php within the comment_form function .