You appear to be a bot. Output may be restricted
Description
Outputs a complete commenting form for use within a template.
Most strings and form fields may be controlled through the $args
array passed into the function, while you may also choose to use the comment_form_default_fields filter to modify the array of default fields if you'd just like to add a new one or remove a single field. All fields are also individually passed through a filter of the comment_form_field_$name where $name
is the key used in the array of fields.
Usage
comment_form( $args, $post_id );
Parameters
- $args
- ( array ) optional – { Optional. Default arguments and form fields to override.
- $fields
- ( array ) optional – { Default comment fields, filterable by default via the comment_form_default_fields hook.
- $author
- ( string ) optional – Comment author field HTML.
- ( string ) optional – Comment author email field HTML.
- $url
- ( string ) optional – Comment author URL field HTML.
- $cookies
- ( string ) optional – Comment cookie opt-in field HTML. }
- $comment_field
- ( string ) optional – The comment textarea field HTML.
- $must_log_in
- ( string ) optional – HTML element for a 'must be logged in to comment' message.
- $logged_in_as
- ( string ) optional – HTML element for a 'logged in as [user]' message.
- $comment_notes_before
- ( string ) optional – HTML element for a message displayed before the comment fields if the user is not logged in. Default 'Your email address will not be published.'.
- $comment_notes_after
- ( string ) optional – HTML element for a message displayed after the textarea field.
- $action
- ( string ) optional – The comment form element action attribute. Default '/wp-comments-post.php'.
- $id_form
- ( string ) optional – The comment form element id attribute. Default 'commentform'.
- $id_submit
- ( string ) optional – The comment submit element id attribute. Default 'submit'.
- $class_container
- ( string ) optional – The comment form container class attribute. Default 'comment-respond'.
- $class_form
- ( string ) optional – The comment form element class attribute. Default 'comment-form'.
- $class_submit
- ( string ) optional – The comment submit element class attribute. Default 'submit'.
- $name_submit
- ( string ) optional – The comment submit element name attribute. Default 'submit'.
- $title_reply
- ( string ) optional – The translatable 'reply' button label. Default 'Leave a Reply'.
- $title_reply_to
- ( string ) optional – The translatable 'reply-to' button label. Default 'Leave a Reply to %s', where %s is the author of the comment being replied to.
- $title_reply_before
- ( string ) optional – HTML displayed before the comment form title. Default: '<h3 id="reply-title" class="comment-reply-title">'.
- $title_reply_after
- ( string ) optional – HTML displayed after the comment form title. Default: '</h3>'.
- $cancel_reply_before
- ( string ) optional – HTML displayed before the cancel reply link.
- $cancel_reply_after
- ( string ) optional – HTML displayed after the cancel reply link.
- $cancel_reply_link
- ( string ) optional – The translatable 'cancel reply' button label. Default 'Cancel reply'.
- $label_submit
- ( string ) optional – The translatable 'submit' button label. Default 'Post a comment'.
- $submit_button
- ( string ) optional – HTML format for the Submit button. Default: '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />'.
- $submit_field
- ( string ) optional – HTML format for the markup surrounding the Submit button and comment hidden fields. Default: '<p class="form-submit">%1$s %2$s</p>', where %1$s is the submit button markup and %2$s is the comment hidden fields.
- $format
- ( string ) optional – The comment form format. Default 'xhtml'. Accepts 'xhtml', 'html5'. }
- $post_id
- ( int|WP_Post ) optional – Post ID or WP_Post object to generate the form for. Default current post.
Returns
void
Source
File name: wordpress/wp-includes/comment-template.php
Lines:
101 to 200 of 423
$args = array_merge( $defaults, $args ); // Remove `aria-describedby` from the email field if there's no associated description. if ( isset( $args['fields']['email'] ) && false === strpos( $args['comment_notes_before'], 'id="email-notes"' ) ) { $args['fields']['email'] = str_replace( ' aria-describedby="email-notes"', '', $args['fields']['email'] ); }