2013-10-03 67 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歲多的問題,但它是我得到了關於這個問題的極少數的結果之一,所以以爲我會在回覆的情況下它可以幫助別人。