How to Customize the WordPress Comment Form

September 12, 2025
How to Customize the WordPress Comment Form

The default WordPress comment form is functional but often needs customization to fit your site’s style or requirements. You can change field order, labels, placeholders, add new fields, or even remove fields using simple code snippets in your theme’s functions.php or a custom plugin. Here’s how to customize the WordPress comment form step by step.


Method 1: Change Default Field Labels and Placeholders

<?php
function my_comment_form_fields( $fields ) {
    // Change 'author' field
    $fields['author'] = '<p class="comment-form-author">
        <label for="author">Your Name</label>
        <input id="author" name="author" type="text" placeholder="Enter your name" required />
    </p>';

    // Change 'email' field
    $fields['email'] = '<p class="comment-form-email">
        <label for="email">Email Address</label>
        <input id="email" name="email" type="email" placeholder="Enter your email" required />
    </p>';

    return $fields;
}
add_filter( 'comment_form_default_fields', 'my_comment_form_fields' );
?>

This replaces the default “Name” and “Email” fields with custom labels and placeholders.


Method 2: Customize the Comment Textarea

<?php
function my_comment_textarea( $defaults ) {
    $defaults['comment_field'] = '<p class="comment-form-comment">
        <label for="comment">Your Comment</label>
        <textarea id="comment" name="comment" rows="5" placeholder="Type your comment here..." required></textarea>
    </p>';
    return $defaults;
}
add_filter( 'comment_form_defaults', 'my_comment_textarea' );
?>

Method 3: Remove Website (URL) Field

The website field is often unnecessary and a common spam target. You can remove it like this:

<?php
function my_remove_comment_url_field( $fields ) {
    if ( isset( $fields['url'] ) ) {
        unset( $fields['url'] );
    }
    return $fields;
}
add_filter( 'comment_form_default_fields', 'my_remove_comment_url_field' );
?>

Method 4: Reorder Fields

By default, “Comment” appears after the name/email fields. You can move it above:

<?php
function my_move_comment_field_to_bottom( $fields ) {
    $comment_field = $fields['comment'];
    unset( $fields['comment'] );
    $fields['comment'] = $comment_field;
    return $fields;
}
add_filter( 'comment_form_fields', 'my_move_comment_field_to_bottom' );
?>

Method 5: Add a Custom Field

Example: Add a “Phone Number” field.

<?php
function my_add_phone_field( $fields ) {
    $fields['phone'] = '<p class="comment-form-phone">
        <label for="phone">Phone Number (optional)</label>
        <input id="phone" name="phone" type="text" />
    </p>';
    return $fields;
}
add_filter( 'comment_form_default_fields', 'my_add_phone_field' );
?>

To save and display the custom field:

<?php
// Save custom field
function my_save_comment_meta( $comment_id ) {
    if ( isset( $_POST['phone'] ) ) {
        add_comment_meta( $comment_id, 'phone', sanitize_text_field( $_POST['phone'] ) );
    }
}
add_action( 'comment_post', 'my_save_comment_meta' );

// Display custom field
function my_show_comment_meta( $comment_text, $comment ) {
    $phone = get_comment_meta( $comment->comment_ID, 'phone', true );
    if ( $phone ) {
        $comment_text .= '<p class="comment-phone"><strong>Phone:</strong> ' . esc_html( $phone ) . '</p>';
    }
    return $comment_text;
}
add_filter( 'comment_text', 'my_show_comment_meta', 10, 2 );
?>

Method 6: Style the Comment Form with CSS

.comment-form input,
.comment-form textarea {
  width: 100%;
  padding: 10px;
  margin-bottom: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
}
.comment-form label {
  font-weight: bold;
  margin-bottom: 5px;
  display: block;
}
.comment-form .form-submit input {
  background: #0073aa;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
}
.comment-form .form-submit input:hover {
  background: #005177;
}

Summary

  1. Use comment_form_default_fields to edit, remove, or add fields like Name, Email, or custom inputs.
  2. Use comment_form_defaults to customize the comment textarea.
  3. Reorder fields with comment_form_fields.
  4. Add custom fields and save/display their data with hooks like comment_post and comment_text.
  5. Style the form with CSS for a better user experience.

With these techniques, you can completely customize the WordPress comment form to match your site’s needs and branding.

Avatar

Written by

satoshi

I’ve been building and customizing WordPress themes for over 10 years. In my free time, you’ll probably find me enjoying a good football match.