我怎么能拉到最顶层的评论表单底部

时间:2017-06-29 08:58:10

标签: wordpress custom-wordpress-pages

this answer

如何将评论字段置于底部,名称电子邮件网站字段可以保持在最顶层这是我的以下代码。

$commenter = wp_get_current_commenter();

        $fields = array(

            'author' =>
                '<div class="form-group"><label for="author">' . __( 'Name', 'hanford' ) . '</label> <span class="required">*</span> <input id="author" name="author" type="text" class="form-control" value="' . esc_attr( $commenter['comment_author'] ) . '" required="required" /></div>',

            'email' =>
                '<div class="form-group"><label for="email">' . __( 'Email', 'hanford' ) . '</label> <span class="required">*</span><input id="email" name="email" class="form-control" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" required="required" /></div>',

            'url' =>
                '<div class="form-group last-field"><label for="url">' . __( 'Website', 'hanford' ) . '</label><input id="url" name="url" class="form-control" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" /></div>'

        );

        $args = array(

            'class_submit' => '',
            'label_submit' => __( 'Post Comment' ),
            'comment_field' =>
                '<div class="form-group"><label for="comment">' . _x( 'Comment', 'hanford' ) . '</label> <span class="required">*</span><textarea id="comment" class="form-control" name="comment" rows="4" required="required"></textarea></p>',
            'fields' => apply_filters( 'comment_form_default_fields', $fields )

        );

        comment_form( $args ); 

1 个答案:

答案 0 :(得分:0)

您可以使用comment_form_fields过滤器。请在您的function.php文件中添加以下代码。了解更多信息click here

function wpb_move_comment_field_to_bottom( $fields ) {
    $comment_field = $fields['comment'];
    unset( $fields['comment'] );
    //print_r($fields);
    $fields['comment'] = $comment_field;
    return $fields;
}
add_filter( 'comment_form_fields', 'wpb_move_comment_field_to_bottom',99,1 );