Filters for comment-related text and behaviour.
Jump to
- Comments title and form text
- Comment form fields
- Single comment
Comments title and form text
generate_comments_title_output
GP Free
The generate_comments_title_output filter allows you to change the output of the comment title element.
Parameters: $value. Default: shown right, computed at render time:
sprintf(
'<h2 class="comments-title">%s</h2>',
esc_html( $comments_title )
)
add_filter( 'generate_comments_title_output', function( $output, $comments_title ) {
return sprintf(
'<p class="comments-title">%s</p>',
esc_html( $comments_title )
);
}, 10, 2 );
Guide: Blog
generate_comment_form_title
GP Free
The generate_comment_form_title filter allows you to change the default # thoughts on {post_title} text.
Parameters: $value (string). Default: # thoughts on {post_title}.
add_filter( 'generate_comment_form_title', function() {
return 'What do others say';
} );
Guide: Blog
generate_leave_comment
GP Free
The generate_leave_comment filter allows you to change the default Leave a Comment text.
Parameters: $value (string). Default: Leave a Comment.
add_filter( 'generate_leave_comment','tu_custom_leave_comment' );
function tu_custom_leave_comment() {
return 'Join the conversation';
}
Guide: Blog
generate_post_comment
GP Free
The generate_post_comment filter allows you to change the default Post Comment text.
Parameters: $value (string). Default: Post Comment.
add_filter( 'generate_post_comment', function( $value ) {
return $value;
} );
Guide: Blog
Comment form fields
comment_form_default_fields
GP Free
The comment_form_default_fields filter (a WordPress core filter) sets the markup for the comment form’s Name, Email and Website fields; GeneratePress hooks into it (generate_filter_comment_fields()) to replace their visible <label> text with placeholder text and a screen-reader label instead.
Parameters: $fields (array, keyed author, email, url — each an HTML string). Default: GeneratePress’s placeholder-based markup for each field (falls back to WordPress core’s own labelled markup if GeneratePress is deactivated).
add_filter( 'comment_form_default_fields', function( $fields ) {
$fields['url'] = ''; // Remove the Website field.
return $fields;
}, 20 );
Guide: Blog
Single comment
generate_add_comment_date_link
GP Free
The generate_add_comment_date_link allows you to disable the default comment date link.
Parameters: $value. Default: true.
add_filter( 'generate_add_comment_date_link', '__return_false' );
Guide: Blog