Wordpress自定义评论表单


wordpress custom comment form

我有一个问题,我想在评论表单中插入,为每个字段一个div。我写这段代码:

<?php comment_form(
$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><div id="end-contenuto-post"></div>',
'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>',
'title_reply'=>'Lascia un commento',
'comment_notes_before' => '<p class="comment-notes">I campi contrassegnati da  <span class="required">*</span> sono obbligatori</p>',
)); ?>

错误在'author'字段:

<div id="end-contenuto-post"></div>

这个HTML不输出…为什么?

你声明这些变量了吗,

$commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );

当它告诉你传递一个数组作为你的参数时,你不做$fields = array(..),而只是使用array(..)或在comment_form()函数之外定义你的数组,然后将其作为参数传递。

请查看文档或本教程