Using WordPress ‘comment_form_fields’ PHP filter

The comment_form_fields WordPress PHP filter allows you to modify the comment form fields, including the textarea.


add_filter('comment_form_fields', 'my_custom_comment_form_fields');
function my_custom_comment_form_fields($comment_fields) {
    // your custom code here
    return $comment_fields;


  • $comment_fields (array): An array containing the comment form fields.

More information

See WordPress Developer Resources: comment_form_fields


Reordering the comment form fields

Reorder the comment form fields to display the textarea before the other fields.

add_filter('comment_form_fields', 'my_custom_reorder_comment_form_fields');
function my_custom_reorder_comment_form_fields($comment_fields) {
    // Move the comment field to the start of the array
    $comment_field = $comment_fields['comment'];
    array_unshift($comment_fields, $comment_field);

    return $comment_fields;

Adding a custom field to the comment form

Add a custom field to the comment form for the user’s website.

add_filter('comment_form_fields', 'my_custom_add_website_field');
function my_custom_add_website_field($comment_fields) {
    // Add a custom website field
    $comment_fields['website'] = '<input type="text" name="website" placeholder="Website">';

    return $comment_fields;

Removing the email field from the comment form

Remove the email field from the comment form.

add_filter('comment_form_fields', 'my_custom_remove_email_field');
function my_custom_remove_email_field($comment_fields) {
    // Remove the email field

    return $comment_fields;