Theme & Front End PHP Beginner

Change the Comment Form Title and Button

Change "Leave a Reply", the "Post Comment" button and the notes above the comment form.

Tested on WordPress 7.1 PHP 8.3 No plugin needed Updated
functions.php 6 lines
add_filter( 'comment_form_defaults', function ( array $defaults ): array {
	$defaults['title_reply']          = 'Join the conversation';
	$defaults['label_submit']         = 'Post comment';
	$defaults['comment_notes_before'] = '<p class="comment-notes">Your email address won\'t be published. Please keep it friendly.</p>';
	return $defaults;
} );

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

The comment form’s wording is generic. Changing the heading and button text to fit your site’s voice is a small touch that can encourage more comments.

How it works

comment_form_defaults holds every piece of text and markup the comment form uses. title_reply is the heading, label_submit the button and comment_notes_before the note above the fields. Other keys include title_reply_to (when replying to someone) and comment_notes_after.

Things to watch

  • Some themes set their own values. If yours ignores the change, use a later priority, such as 20.
  • Block themes use the Comments Form block, which takes its text from the same defaults.

How to test it

Open a post with comments enabled. The form should show your new heading and button text.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only