apply_filters( ‘comment_form_defaults’, array $defaults )

Filters the comment form default arguments.

Description

Use ‘comment_form_default_fields’ to filter the comment fields.

Parameters

$defaultsarray
The default comment form arguments.

Source

$args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) );

Changelog

VersionDescription
3.0.0Introduced.

User Contributed Notes

  1. Skip to note 3 content

    The following defaults are possible to set with this code:

    function wpdocs_set_comment_form_defaults( $defaults ) {
    	//Here you are able to change the $defaults[]
    	//For example: 
    	$defaults['title_reply'] = __( 'Add a Comment' );
    	
    	return $defaults;
    }
    add_filter( 'comment_form_defaults', 'wpdocs_set_comment_form_defaults' );

    Possible values for $defaults[ ‘…’ ]:

    • fields

      • author
      • email
      • url
      • cookies
      • comment
    • comment_field
    • must_log_in
    • logged_in_as
    • comment_notes_before
    • comment_notes_after
    • action
    • id_form
    • id_submit
    • name_submit
    • title_reply
    • title_reply_to
    • title_reply_before
    • title_reply_after
    • cancel_reply_before
    • cancel_reply_after
    • cancel_reply_link
    • label_submit
    • submit_button
    • submit_field
    • format
  2. Skip to note 4 content

    Example for overriding the title of the comment form (default ‘Leave a Reply’) from within a theme’s functions.php in the theme setup function:

      function wpdocs_comment_form_defaults( $defaults ) {
        $defaults['title_reply'] = __( 'Add a Comment' );
        return $defaults;
      }
      add_filter( 'comment_form_defaults', 'wpdocs_comment_form_defaults' );

You must log in before being able to contribute a note or feedback.