如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款
comment_form( array $args = array(), int|WP_Post $post_id = null )
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>‘comment_form_field_$name’ where $name is the key used in the array of fields.
参数
- $args
(array)
(Optional)
Default arguments and form fields to override.
- 'fields'
(array) Default comment fields, filterable by default via the 'comment_form_default_fields' hook.- 'author'
(string) Comment author field HTML. - 'email'
(string) Comment author email field HTML. - 'url'
(string) Comment author URL field HTML. - 'cookies'
(string) Comment cookie opt-in field HTML.
- 'comment_field'
(string) The comment textarea field HTML. - 'must_log_in'
(string) HTML element for a 'must be logged in to comment' message. - 'logged_in_as'
(string) HTML element for a 'logged in as [user]' message. - 'comment_notes_before'
(string) 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) HTML element for a message displayed after the textarea field. - 'action'
(string) The comment form element action attribute. Default '/wp-comments-post.php'. - 'id_form'
(string) The comment form element id attribute. Default 'commentform'. - 'id_submit'
(string) The comment submit element id attribute. Default 'submit'. - 'class_form'
(string) The comment form element class attribute. Default 'comment-form'. - 'class_submit'
(string) The comment submit element class attribute. Default 'submit'. - 'name_submit'
(string) The comment submit element name attribute. Default 'submit'. - 'title_reply'
(string) The translatable 'reply' button label. Default 'Leave a Reply'. - 'title_reply_to'
(string) 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) HTML displayed before the comment form title. Default: <h3 id="reply-title" class="comment-reply-title">. - 'title_reply_after'
(string) HTML displayed after the comment form title. Default: </h3>. - 'cancel_reply_before'
(string) HTML displayed before the cancel reply link. - 'cancel_reply_after'
(string) HTML displayed after the cancel reply link. - 'cancel_reply_link'
(string) The translatable 'cancel reply' button label. Default 'Cancel reply'. - 'label_submit'
(string) The translatable 'submit' button label. Default 'Post a comment'. - 'submit_button'
(string) HTML format for the Submit button. Default: <input name="%1$s" type="submit" id="%2$s" class="%3$s" value=https://developer.wordpress.org/reference/functions/comment_form/"%4$s" />. - 'submit_field'
(string) 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) The comment form format. Default 'xhtml'. Accepts 'xhtml', 'html5'.
Default value: array()
- $post_id
(int|WP_Post)
(Optional)
Post ID or WP_Post object to generate the form for. Default current post.
Default value: null