admin管理员组文章数量:1323377
I’ve put the class for 'logged_in_as' into another container to display the content in another column:
<div id="content-form">
<?php
$fields = array(
'author' => '<div class="right_col"><p class="comment-form-author">
<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
'email' => '<p class="comment-form-email">
<input id="email" name="email" type="text" value="Name' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
'url' => '<p class="comment-form-url">
<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p></div>',
);
comment_form( array(
'label_submit' => 'Beitrag kommentieren',
'title_reply' => '',
'fields' => apply_filters(
'comment_form_default_fields', $fields ),
'comment_notes_before' => '',
'comment_notes_after' => '',
'logged_in_as' => '<div class="right_col"><p class="logged-in-as">'
. sprintf(
__( 'Logged in as <a href="%s">%s</a> .
<a href="%s" title="Log out of this account">Log out?</a></p></div>'
)
, admin_url( 'profile.php' )
, $user_identity
, wp_logout_url( apply_filters( 'the_permalink'
, get_permalink( $post_id )
)
)
)
?>
</div>
But the submit-button for the comment-field (which is in the left column) only displays after the content of 'logged_in_as'.
But I want to place the submit-button on the left side below the comment-field. How can I place the Submit-Button before the 'logged_in_as'-Content?
I’ve put the class for 'logged_in_as' into another container to display the content in another column:
<div id="content-form">
<?php
$fields = array(
'author' => '<div class="right_col"><p class="comment-form-author">
<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
'email' => '<p class="comment-form-email">
<input id="email" name="email" type="text" value="Name' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
'url' => '<p class="comment-form-url">
<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p></div>',
);
comment_form( array(
'label_submit' => 'Beitrag kommentieren',
'title_reply' => '',
'fields' => apply_filters(
'comment_form_default_fields', $fields ),
'comment_notes_before' => '',
'comment_notes_after' => '',
'logged_in_as' => '<div class="right_col"><p class="logged-in-as">'
. sprintf(
__( 'Logged in as <a href="%s">%s</a> .
<a href="%s" title="Log out of this account">Log out?</a></p></div>'
)
, admin_url( 'profile.php' )
, $user_identity
, wp_logout_url( apply_filters( 'the_permalink'
, get_permalink( $post_id )
)
)
)
?>
</div>
But the submit-button for the comment-field (which is in the left column) only displays after the content of 'logged_in_as'.
But I want to place the submit-button on the left side below the comment-field. How can I place the Submit-Button before the 'logged_in_as'-Content?
Share Improve this question edited Sep 11, 2012 at 17:37 Nitzki asked Aug 27, 2012 at 21:37 NitzkiNitzki 1951 gold badge1 silver badge11 bronze badges 3- 1 Hi, I’ve edited my question. Maybe it was a bit confusing. But I just want to know, if there is a way to change the order. – Nitzki Commented Aug 28, 2012 at 9:22
- I've edited your code for legibility - you'll be able to see it once the edit has been 'approved.' They way you had it formatted made it too hard to understand what it was doing. – marfarma Commented Sep 11, 2012 at 15:09
- 1 Thanks for your help. I’ve added the complete code for the comment_form. – Nitzki Commented Sep 11, 2012 at 17:30
2 Answers
Reset to default 2You don't change the ordering, essentially. If you need to reposition things on the page, you should use CSS. That's what it's for.
The submit button is in a P with a class of form-submit. You can use that to move it around with CSS.
8 Years ago maybe it was like this, but now you specify it in your functions.php (for all the people coming across this thread now)
//Comment Field Order
add_filter( 'comment_form_fields', 'mo_comment_fields_custom_order' );
function mo_comment_fields_custom_order( $fields ) {
$comment_field = $fields['comment'];
$author_field = $fields['author'];
$email_field = $fields['email'];
$url_field = $fields['url'];
$cookies_field = $fields['cookies'];
unset( $fields['comment'] );
unset( $fields['author'] );
unset( $fields['email'] );
unset( $fields['url'] );
unset( $fields['cookies'] );
// the order of fields is the order below, change it as needed:
$fields['author'] = $author_field;
$fields['email'] = $email_field;
$fields['url'] = $url_field;
$fields['comment'] = $comment_field;
$fields['cookies'] = $cookies_field;
// done ordering, now return the fields:
return $fields;
}
本文标签: comment formHow to change the order of elements in commentform()
版权声明:本文标题:comment form - How to change the order of elements in comment_form() 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742120945a2421693.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论