Site logo

Archived topic

Customize text on comment form

3 replies · Started by Chad on May 22, 2020

Viewing posts 1–4 of 4

I am trying to change the text on the comment form.

Rather than it show things like "Leave a Comment" or the submit button having "Post Comment" -- I want it to say "Leave an Answer" and "Post Answer."

I attempted to do this like so:

function change_comment_form( $defaults ) {
	$defaults['comment_field'] = sprintf(
		'<p class="comment-form-comment"><label for="comment" class="screen-reader-text">%1$s</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>',
		esc_html__( 'Comment', 'generatepress' )
	);

	$defaults['comment_notes_before']	= null;
	$defaults['comment_notes_after']	= null;
	$defaults['id_form'] 				= 'answerform';
	$defaults['id_submit'] 				= 'submit';
	$defaults['title_reply'] 			= apply_filters( 'generate_leave_comment', __( 'Leave an Answer', 'generatepress' ) );
	$defaults['label_submit'] 			= apply_filters( 'generate_post_comment', __( 'Post Answer', 'generatepress' ) );

	return $defaults;
}

add_filter( 'comment_form_default_fields', 'change_comment_form' );

But it doesn't work and I'm sure it's probably not the way you'd prefer.

Please advise.

Thank you.

Yep, worked perfectly. Thanks!

No problem :)

This archived topic is closed to new replies.