WordPress.org

Ready to get started?Download WordPress

Forums

Twenty Eleven Theme, Change the Form Fields and if they're required (1 post)

  1. CiaranA
    Member
    Posted 1 year ago #

    Hi,

    I'm using the Twenty Eleven child theme and have a site where I want people to be able to post comments to armed forces. The form fields 'Name' and 'Email' are by default required for the comment to operate however I only want 'Name'.

    I've looked in comments.php and added my own code (see below) into there which doesn't have 'Email' and has the required line taken out of 'Name' but I still get taken to a page which states I need both to be able to comment. Any suggestions?

    <?php
    $comment_args = array(
    'fields' => apply_filters(
    'comment_form_default_fields', array(
    'author' => '<p class="comment-form-author">' .
    '<label for="author">' . __( 'Your Name' ) . '</label> ' .
    '<input id="author" name="author" type="text" value="' .
    esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' />' .
    '</p><!-- #form-section-author .form-section -->',
    'url' => ''
    )
    ),
    'comment_field' => '<p class="comment-form-comment">' .
    '<label for="comment">' . __( 'Let us know what you have to say:' ) . '</label>' .
    '<textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea>' .
    '</p><!-- #form-section-comment .form-section -->',
    'comment_notes_after' => '',
    'title_reply' => 'Please Post Your Comments & Reviews'
    );
    comment_form( $comment_args );
    ?>

    Oh and also hen posting the above code into comments.php I get two forms being generated. However there is no other code in there which relates to the comment form. Little bit confused.

    Thanks in advance for any help.

Topic Closed

This topic has been closed to new replies.

About this Topic