Shibbir
Shibbir

Reputation: 2031

How can I put the comments box bellow the name and email input box in WordPress?

I have this comment form when I logged out:

enter image description here

Now, I want to move this message box to below the name and email box?

can you tell me how can I do this?

functions.php code:

function comment_default_fields ( $fields ) {   

    unset($fields['author']);
    unset($fields['email']);
    unset($fields['url']);    

    $fields[]           = '<div class="row">'; 
    $fields['author']   = '<div class="col-lg-6 col-md-6">
                <div class="single-input">
                    <label for="commenter-name">Name</label>
                    <input type="text" name="commenter-name" id="commenter-name" placeholder="Your name here..">
                </div>
            </div>';
    $fields['email']    =   '<div class="col-lg-6 col-md-6">
                <div class="single-input">
                    <label for="commenter-email">Email</label>
                    <input type="email" name="commenter-email" id="commenter-email" placeholder="Your email here..">
                </div>
            </div>';

    $fields[]           = '</div>';             
    return $fields;
}
add_filter( 'comment_form_default_fields', 'comment_default_fields' );

comments.php code

$comments_args = array(        
        'label_submit'=>'Submit Your Comment',        
        'title_reply'=>'Write a Reply or Comment',    
        'comment_field' => '<div class="row"><div class="col-lg-12">
                <div class="single-input">
                    <label for="commenter-message">Message</label>
                    <textarea name="comment" id="commenter-message" cols="30" rows="5" placeholder="Your message here.."></textarea>
                </div>
            </div></div>',
        'submit_button' =>  '<div class="row"><div class="col-lg-12">
                <div class="single-input">
                    <input name="submit" type="submit" id="submit" class="submit cr-btn" value="Submit Your Comment">                    
                </div>
            </div></div>'
);


echo '<div class="blog-details-block commentbox">';
comment_form($comments_args);
echo '</div>';

Upvotes: 1

Views: 602

Answers (1)

LebCit
LebCit

Reputation: 638

Add this to your functions.php

function move_comment_field_to_bottom( $fields ) {
    $comment_field = $fields['comment'];
    unset( $fields['comment'] );
    $fields['comment'] = $comment_field;
    return $fields;
}
add_filter( 'comment_form_fields', 'move_comment_field_to_bottom' );  

Please, remember to use a child theme for all of your changes otherwise they will be removed on the next update of the theme you are using.

Upvotes: 2

Related Questions