如何更改COMMENT_FORM()中元素的顺序

时间:2012-08-27 作者:Nitzki

我已将“logged\\u in\\u as”的类放入另一个容器中,以在另一列中显示内容:

    <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>
但注释字段(位于左列)的提交按钮仅显示在“logged\\u in\\u as”内容之后。screenshot of the comment-form

但我想把提交按钮放在评论栏下方的左侧。如何将提交按钮放在“logged\\u in\\u as”内容之前?

2 个回复
最合适的回答,由SO网友:Otto 整理而成

基本上,您不会更改顺序。如果需要重新定位页面上的内容,应该使用CSS。这就是为什么。

submit按钮位于P中,其类为表单submit。你可以用它来移动CSS。

SO网友:thedoomer1000

8年前可能是这样,但现在你在函数中指定了它。php(适用于所有现在遇到此线程的人)

//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;
}

结束

相关推荐