Support » Plugins » Hacks » change position of field label for comment form fields

  • I would like to change the formatting of the comments form. I am using a theme based upon twentyten, which displays the label of a form element to the left of the form element.

    Email * [email form element]

    Instead I want to display the label for the form element to the right of the form element.

    [email form element] Email *

    I assume I would use the $fields array to specify the HTML for each form element and somehow pass that to the comment_form() but I don’t how to do this.

    How do I accomplish this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Just edit your comments template found under

    ..or what it is called. Been 5 months since i created a theme. 🙂

    [signature removed per forum etiquette]

    Thanks for the suggestion. I wanted to avoid building a new template just for the form and rely on a programmatic solution.

    I was able to use a filter to change the position of the label tag for the email and author fields. However the required mark no longer displays for these two fields.

    The documentation for the comment_form() under $fields uses a $req variable. I am not sure if this is a legit wordpress variable or just something in the example.

    I copied these example form element HTML strings, but the $req variable is probably not correctly used in my code. I tried using global in my filter function but that did not fix the problem.


    function modify_form($updated_fields){
    global $req;
    $updated_fields[‘author’] = ‘revised html’ . ( $req ? ‘<span class=”required”>*</span>’ : ” );
    $updated_fields[’email’] = ‘revised html’ . . ( $req ? ‘<span class=”required”>*</span>’ : ” );
    return $updated_fields;
    add_filter(‘comment_form_default_fields’, ‘modify_form’);

    How do I know if a field is required?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘change position of field label for comment form fields’ is closed to new replies.