Title: modifying comment_form() output
Last modified: February 6, 2017

---

# modifying comment_form() output

 *  [olliew](https://wordpress.org/support/users/olliew/)
 * (@olliew)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/modifying-comment_form-output/)
 * I would like to wrap the name, email and website labels and inputs and the submit
   button into one div (but not the comment textarea).
    I’m sure this will involve
   using either comment_form_default_fields or just passing arguments to comment_form()
   but as a newbie to WordPress I’m not that sure of what to do. I want to achieve
   the following code: <div> <p class=”comment-form-author”>…</p> <p class=”comment-
   form-email”>…</p> <p class=”comment-form-url”>…</p> <p class=”form-submit”>…</
   p> </div>

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/modifying-comment_form-output/#post-8745316)
 * There’s no comment_form() argument to achieve what you want. You could use the‘
   comment_form_fields’ filter to add a <div> in front of the first field after 
   the textarea, and add a </div> to the last field. Or use the ‘comment_form’ filter
   to alter the entire content inside the <form> element. You’d need to parse through
   the content to locate the closing </textarea> in order to properly locate your
   <div>.
 *  [Anastis Sourgoutsidis](https://wordpress.org/support/users/anastis/)
 * (@anastis)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/modifying-comment_form-output/#post-8756360)
 * The action hooks ‘comment_form_before_fields’ and ‘comment_form_after_fields’
   are what you are looking for. You can print the opening and closing div respectively.
 * The comment’s textarea is printed after ‘comment_form_after_fields’ executes,
   so it fits just right.
 * You can check the code/comments in the function definition of comment_form() 
   in wp-includes/comment-template.php lines 2360-2405 and you’ll see that the textarea
   gets treated differently.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘modifying comment_form() output’ is closed to new replies.

## Tags

 * [Comments](https://wordpress.org/support/topic-tag/comments/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 3 participants
 * Last reply from: [Anastis Sourgoutsidis](https://wordpress.org/support/users/anastis/)
 * Last activity: [9 years, 4 months ago](https://wordpress.org/support/topic/modifying-comment_form-output/#post-8756360)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
