Using WordPress ‘comment_form_defaults’ PHP filter

The comment_form_defaults WordPress PHP filter allows you to modify the default arguments of the comment form.


add_filter('comment_form_defaults', 'customize_comment_form_defaults');

function customize_comment_form_defaults($defaults) {
    // Your custom code here

    return $defaults;


  • $defaults: (array) The default comment form arguments.

More information

See WordPress Developer Resources: comment_form_defaults


Change the submit button text

Customize the submit button text of the comment form.

function change_submit_button_text($defaults) {
    $defaults['label_submit'] = 'Post Comment';
    return $defaults;
add_filter('comment_form_defaults', 'change_submit_button_text');

Modify the title

Change the comment form title.

function modify_comment_form_title($defaults) {
    $defaults['title_reply'] = 'Share your thoughts';
    return $defaults;
add_filter('comment_form_defaults', 'modify_comment_form_title');

Remove website field

Remove the website field from the comment form.

function remove_website_field($defaults) {
    return $defaults;
add_filter('comment_form_defaults', 'remove_website_field');

Change the comment textarea label

Customize the label for the comment textarea.

function change_comment_textarea_label($defaults) {
    $defaults['comment_field'] = '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" required="required"></textarea></p>';
    return $defaults;
add_filter('comment_form_defaults', 'change_comment_textarea_label');

Set a custom comment form class

Add a custom class to the comment form.

function set_comment_form_class($defaults) {
    $defaults['class_form'] = 'custom-comment-form';
    return $defaults;
add_filter('comment_form_defaults', 'set_comment_form_class');