With the latest version of WordPress, I'm working in my child theme. I have enabled comments on a specific page. I can see OOTB I have author, email, website and comments input areas enabled.

From my functions.php location. I would like to only hide my website field, and change the label of the comments field, from "comment" to "Leave a Review". I have tried the following below, but its hiding everything except the textarea box for "Leave a Review. How can I also bring Author, Email, and Cookie input fields back?

function _ac_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'] );
    $fields['author'] = $author_field;
    $fields['email'] = $email_field;  
    $fields = [ 
        'comment_field' => sprintf(
        '<p class="comment-form-comment">%s %s</p>',
            '<label for="comment">%s</label>',
            _x( 'Your Review', 'noun' )
        '<textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" required="required"></textarea>'

    $fields['cookies'] = $cookies_field;
    // done ordering, now return the fields:
    return $fields;
add_filter( 'comment_form_fields', '_ac_comment_fields_custom_order' );

1 Answer 1


You are redeclaring the variable $fields after you define the email key - this basically removes all previous values - instead you need to add a new key for comment_field, for example:

    // retain code before..

    $fields['author'] = $author_field;
    $fields['email'] = $email_field;  
    $fields['comment_field'] = sprintf(
        '<p class="comment-form-comment"><label for="comment">%s</label><textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" required="required"></textarea></p>',            
        __( 'Your Review', 'theme-textdomain' )

    $fields['cookies'] = $cookies_field;

    // retain code after..

I also reduced your sprintf to one single function, as you only need to use this once, you should also use your own text-domain.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.