WordPress函数文档comment_form()

显示发布评论的对话框 描述 This tag outputs a complete commenting fo…

显示发布评论的对话框

描述

This tag 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 form comment_form_field_$name where $name is the key used in the array of fields.

Please note, that although most parameters are marked as optional, not including them all in your code will produce errors when using define('WP_DEBUG', true);

用法

<?php comment_form$args$post_id ); ?>

Default Usage

<?php comment_form(); ?>

twentytendefault6.png

As seen in the popular twentyten theme – called here: wp-content/themes/twentyten/comments.php

参数

args

(array) (可选) Options for strings, fields etc in the form.

默认值: (See below)

post_id

(mixed) (可选) Post ID to generate the form for, uses the current post if null

默认值: null (the current post)

$args

Note: If you change the $defaults in your comments template using $new_defaults, you must declare the $new_defaults BEFORE you call comment_form($new_defaults);, otherwise, they won’t take effect.

Default values:

fields

(array) (可选) Input fields: ‘author’, ’email’, ‘url’.

默认值: apply_filters( 'comment_form_default_fields', $fields )

comment_field

(string) (可选) The textarea and the label of comment body.

默认值:

must_log_in

(string) (可选)

默认值:

logged_in_as

(string) (可选)

默认值:

comment_notes_before

(string) (可选) Text or HTML to be displayed before the set of comment form fields if the user is not logged in.

默认值:

comment_notes_after

(string) (可选) Text or HTML to be displayed after the set of comment fields (and before the submit button)

默认值:

id_form

(string) (可选) value of the id attribute of form element (<form> tag).

默认值: ‘commentform’

id_submit

(string) (可选) value of the id attribute of submit button.

默认值: ‘submit’

class_submit

(string) (可选) value of the class attribute of submit button.

默认值: ‘submit’

title_reply

(string) (可选) The title of comment form (when not replying to a comment, see comment_form_title).

默认值: __( ‘Leave a Reply’ )

title_reply_to

(string) (可选) The title of comment form (when replying to a comment, see comment_form_title).

默认值: __( ‘Leave a Reply to %s’ )

cancel_reply_link

(string) (可选) link label to cancel reply.

默认值: __( ‘Cancel reply’ )

label_submit

(string) (可选) the name of submit button.

默认值: __( ‘Post Comment’ )

$fields

Default form fields:

Note: To use the variables present in the above code in a custom callback function, you must first set these variables within your callback using:

Default $args array

示例

Simple example how to change some comment form fields.

相关

comments_template()

Comments Function(函数)s

  • Function(函数): cancel_comment_reply_link()
  • Function(函数): comment_author()
  • Function(函数): comment_author_email()
  • Function(函数): comment_author_email_link()
  • Function(函数): comment_author_IP()
  • Function(函数): comment_author_link()
  • Function(函数): comment_author_rss()
  • Function(函数): comment_author_url()
  • Function(函数): comment_author_url_link()
  • Function(函数): comment_class()
  • Function(函数): comment_date()
  • Function(函数): comment_excerpt()
  • Function(函数): comment_form_title()
  • Function(函数): comment_form(),
  • Function(函数): comment_ID()
  • Function(函数): comment_id_fields()
  • Function(函数): comment_reply_link()
  • Function(函数): comment_text()
  • Function(函数): comment_text_rss()
  • Function(函数): comment_time()
  • Function(函数): comment_type()
  • Function(函数): comments_link
  • Function(函数): comments_number()
  • Function(函数): comments_open(),
  • Function(函数): comments_popup_link()
  • Function(函数): comments_popup_script()
  • Function(函数): comments_rss_link()
  • Function(函数): get_avatar()
  • Function(函数): next_comments_link()
  • Function(函数): paginate_comments_links()
  • Function(函数): permalink_comments_rss()
  • Function(函数): previous_comments_link()
  • Function(函数): wp_list_comments()
  • 原文:http://codex.wordpress.org/Function_Reference/comment_form
类别:WordPress函数文档

本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

评论 (0)COMMENT