The comment_form_fields WordPress PHP filter allows you to modify the comment form fields, including the textarea.
Usage
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; }
Parameters
$comment_fields
(array): An array containing the comment form fields.
More information
See WordPress Developer Resources: comment_form_fields
Examples
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']; unset($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 unset($comment_fields['email']); return $comment_fields; }