我怎样才能从底部拉出字段顶部评论
How i can i pull fields top comment form bottom
enter image description here
如何将评论字段放在底部,而名称电子邮件网站字段可以放在顶部这是我的以下代码。
$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 );
您可以使用 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 );
enter image description here
如何将评论字段放在底部,而名称电子邮件网站字段可以放在顶部这是我的以下代码。
$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 );
您可以使用 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 );