2013-10-03 66 views
0

我有下面的代码自定义注释形式:评论textarea的显示了两次 - 自定义WordPress的评论形式

<?php $fields = array(

    'fields' => apply_filters('comment_form_default_fields', array(

    'author' => 
     '<p class="comment-form-author"><input id="author" name="author" type="text" value="" placeholder="*Please enter your name..." aria-required="true" /></p>', 

    'email' => 
     '<p class="comment-form-email"><input id="email" name="email" type="text" value="" placeholder="*Please enter your email..." aria-required="true" /></p>', 

    'comment_field' => 
     '<p class="comment-form-comment"><textarea id="comment" placeholder="*Please type your message here..." name="comment" cols="45" rows="8" aria-required="true"></textarea></p>', 

    )), 

    'comment_notes_after' => '', 

); ?> 
<div class="comments-form"><?php comment_form($fields); ?></div> 

然而,textarea的显示出来两次,默认的带标签和我的自定义一个没有(见屏幕截图:http://i.imgur.com/SHM0jzi.png)。我怎样才能摆脱默认的?

回答

3

现在解决了。 comment_field不应该在'fields'数组中,因为它是comment_form()函数的独特参数。所以,它应该是:

<?php $fields = array(

    'fields' => apply_filters('comment_form_default_fields', array(

    'author' => 
     '<p class="comment-form-author"><input id="author" name="author" type="text" value="" placeholder="*Please enter your name..." aria-required="true" /></p>', 

    'email' => 
     '<p class="comment-form-email"><input id="email" name="email" type="text" value="" placeholder="*Please enter your email..." aria-required="true" /></p>', 

    )), 

    'comment_field' => 
     '<p class="comment-form-comment"><textarea id="comment" placeholder="*Please type your message here..." name="comment" cols="45" rows="8" aria-required="true"></textarea></p>', 

    'comment_notes_after' => '', 

); ?> 
0

不错的答案,它帮助我。这里是我的解决方案:

$fields = array(
      'author' => '<p class="comment-form-author">' . '<label for="author">' . __('Name') . '</label><br /> ' . ($req ? '<span class="required">*</span>' : '') . 
       '<input id="author" name="author" type="text" size="30"' . $aria_req . ' /></p>', 
      'email' => '<p class="comment-form-email"><label for="email">' . __('Email') . '</label><br /> ' . ($req ? '<span class="required">*</span>' : '') . 
       '<input id="email" name="email" type="text" size="30"' . $aria_req . ' /></p>', 
     ); 

$comments_args = array(
      'fields' => $fields, 
      'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x('Comment', 'noun') . '</label> <br /> <textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" aria-required="true" required="required"></textarea></p>', 
     ); 

comment_form($comments_args); 

我知道这是一个3岁多的问题,但它是我得到了关于这个问题的极少数的结果之一,所以以为我会在回复的情况下它可以帮助别人。