• 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細

このWikiはいつでも誰でも編集できます

関数リファレンス/comment form

提供: WordPress Codex 日本語版
< 関数リファレンス
2010年7月6日 (火) 01:20時点におけるBono (トーク | 投稿記録)による版 (en:Template Tags/comment_form 13:50, 5 July 2010 Bono 版を翻訳用にコピー)

(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索
このページ「関数リファレンス/comment form」はまだ書きかけで、情報が不足しています。続きを書いて WordPress を手助けしましょう.


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

args
array) (optional) Options for strings, fields etc in the form.
初期値: (See below)
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 of form 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

Source Code

comment_form() is located in wp-includes/comment-template.php. (WordPress 5.3)

最新英語版: WordPress Codex » Template Tags/comment_form最新版との差分

Related

テンプレート:Comments Tags


関数リファレンステンプレートタグ目次もご覧ください。