I'm developing a Wordpress theme and I faced a problem while customizing a comment form. What I wanted is to eliminate URL field and put my own classes for name and email fields. I'm doing it like this:

    $commenter = wp_get_current_commenter();
    $req = get_option( 'require_name_email' );
    $aria_req = ( $req ? " aria-required='true'" : '' );
    $fields =  array(
        'author' => '<p class="post-comment-name"><label for="post-comment-name">' . __( 'Name' ) . '</label><input type="text" id="post-comment-name" name="post-comment-name" placeholder="Write your name" value="' . esc_attr( $commenter['comment_author'] ) . '" ' . $aria_req . ' /></p>',
        'email' => '<p class="post-comment-email"><label for="post-comment-email">' . __( 'Email' ) . '</label><input type="text" id="post-comment-email" name="post-comment-email" placeholder="Your email to reply" value="' . esc_attr( $commenter['comment_email'] ) . '" ' . $aria_req . ' /></p>',
        'url' => ''
    $comments_args = array(
        'title_reply' => '',
        'comment_notes_before' => '',
        'id_submit' => 'post-comment-submit',
        'fields' =>  $fields


After all visually I've got what I wanted. I've got form with all the styles I wanted and with no URL field whatsoever.

The problem is when I try to submit the comment form with all the data filled in I get the message: "Fields name and email are required" and comment submission fails.

Tried almost everything, nothing helped. Please assist!

3 Answers 3


You can unset this field like that :

function wpse_109744_comment_form_fields($fields) {
$fields ['email'] = 'your markup';
$fields ['author'] = 'your markup';

$return $fields;
add_filter('comment_form_default_fields', 'wpse_109744_comment_form_fields')


  • Thanks ... but the problem is the Wordpress stops accepting comments from the form this is the main issue.
    – LoomyBear
    Aug 12, 2013 at 11:48
  • I've edited my answer. It's better to use hook such as comment_form_default_fields
    – JMau
    Aug 12, 2013 at 11:58
  • I'm sorry to say this but I still have ERROR: please fill the required fields (name, email).
    – LoomyBear
    Aug 12, 2013 at 12:28
  • There's some additional javascript ?
    – JMau
    Aug 12, 2013 at 13:19
  • I've tried to ajaxify the comments but for the sake of test I turned it off so now it's pure POST requests. The thing is when I comment with logged in user (admin) comments are sent and processed as they supposed to be, but when I try to comment as not logged user (name and email are required) it generates this annoying error. I've noticed that the problem appears when I try to change $fields in anyway. When $fields is left unchanged the comment is processed as expected.
    – LoomyBear
    Aug 12, 2013 at 13:27

I finally made it work.

All you need to do is to preserve id attributes for all the fields when you try to customize them:

$fields =  array(
    'author' => '<input id="my-input-id" />', // Does not work
    'email' => '<input id="email" />', // Works

All you need to do to make it work is to preserve the input id. I don't know maybe there's a way to somehow make WP process comment forms with different input ids, but I failed to find any. Which I think is not a really critical issue but at least it should be mentioned in the codex or smth.

If you have anything to add please do!


I found it finally. you should keep the same name field in both input and textarea.

Example: name="author" & name="email".

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.