- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
関数リファレンス/comment form
このページ「関数リファレンス/comment form」は未翻訳です。和訳や日本語情報を加筆してくださる協力者を求めています。
タグ一覧: テンプレートタグ | インクルードタグ | 条件分岐タグ | その他の関数 | Code Reference
使い方: テンプレートタグ入門 | パラメータの渡し方 | 初心者の方へ | その他のテーマ関連資料
目次
Description
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 comments_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 comments_form_field_$name
where $name
is the key used in the array of fields.
Usage
<?php comment_form( $args, $post_id ); ?>
Default Usage
<?php comment_form(); ?>
cf. wp-content/themes/twentyten/comments.php
Parameters
- post_id
- (mixed) (optional) Post ID to generate the form for, uses the current post if null
- 初期値: null (the current post)
$args
Default value:
<?php $defaults = array( 'fields' => apply_filters( 'comment_form_default_fields', $fields ), 'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>', 'must_log_in' => '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>', 'logged_in_as' => '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>', 'comment_notes_before' => '<p class="comment-notes">' . __( 'Your email address will not be published.' ) . ( $req ? $required_text : '' ) . '</p>', 'comment_notes_after' => '<p class="form-allowed-tags">' . sprintf( __( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s' ), ' <code>' . allowed_tags() . '</code>' ) . '</p>', 'id_form' => 'commentform', 'id_submit' => 'submit', 'title_reply' => __( 'Leave a Reply' ), 'title_reply_to' => __( 'Leave a Reply to %s' ), 'cancel_reply_link' => __( 'Cancel reply' ), 'label_submit' => __( 'Post Comment' ), ); ?>
- fields
- (array) (optional) Input fields other than comment body, such as author, email, url.
- 初期値:
apply_filters( 'comment_form_default_fields', $fields )
- 初期値:
- comment_field
- (string) (optional) The textarea and the label of comment body.
- 初期値:
- must_log_in
- (string) (optional)
- 初期値:
- logged_in_as
- (string) (optional)
- 初期値:
- comment_notes_before
- (string) (optional) text or html tags befor comment form.
- 初期値:
- comment_notes_after
- (string) (optional) text or html tags after comment body.
- 初期値:
- id_form
- (string) (optional) value of the
id
attribute ofform
element (<form>
tag).- 初期値: 'commentform'
- id_submit
- (string) (optional) value of the
id
attribute of submit button.- 初期値: 'submit'
- title_reply
- (string) (optional) The title of comment form.
- 初期値: __( 'Leave a Reply' )
- title_reply_to
- (string) (optional)
- 初期値: __( 'Leave a Reply to %s' )
- cancel_reply_link
- (string) (optional) link label to cancel reply.
- 初期値: __( 'Cancel reply' )
- label_submit
- (string) (optional) the name of submit button.
- 初期値: __( 'Post Comment' )
$fields
Default input items:
<?php $fields = array( 'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>', 'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . '<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>', 'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label>' . '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>', ); ?>
Return
void
Filter
Examples
customizing Input Fields
Changelog
- Since 3.0.0
Source Code
comment_form()
is located in wp-includes/comment-template.php
.
最新英語版: WordPress Codex » Template Tags/comment_form (最新版との差分)
Related