Customizing comments section in WordPress

The following tutorial was originally created years ago. I decided to add on Full Site Editing to where we can modify the comments through the Comments block and associated inner blocks.

Using the Comments block in Full Site Editing themes.
Customizing comments in the Genesis framework.

We now have a Comments block and inner blocks that we can use in Full Site Editing.

These can also be used in the regular classic themes, but currently it is easier to get these working in a FSE theme. More information will be added at another time as more features are added to the Gutenberg plugin and later on in WordPress core.

(Older tutorial) Customizing the comments section of a Genesis child theme.

Tutorial was originally published 8 September 2014. Updated 9 May 2018.

These are specific for the Genesis Framework – StudioPress Themes for WordPress.
Add PHP code to a child theme functions.php file or a code snippet plugin.

Adjusting the comment box title from “Leave a Reply” -> “Leave a Comment”

// Modify the speak your mind title in comments – Comment Box title –
//
add_filter( 'comment_form_defaults', 'sp_comment_form_defaults' );
function sp_comment_form_defaults( $defaults ) {
 $defaults['title_reply'] = __( 'Leave a Comment' );
 return $defaults;
}
// Add or remove notes after the comment box
//
add_filter( 'comment_form_defaults', 'sp_remove_comment_form_allowed_tags' );
function sp_remove_comment_form_allowed_tags( $defaults ) {
 $defaults['comment_notes_after'] = 'An extra comment';
 return $defaults;
}
// Modify the Genesis content limit read more link – Genesis Settings page – Display post content certain amount of characters. I selected 200.
//
add_filter( 'get_the_content_more_link', 'sp_read_more_link' );
function sp_read_more_link() {
 return '… <a class="more-link" href="' . get_permalink() . '">[Read on]</a>';
}
// Changing the mini Comment title to something else http://wpsites.net/web-design/customize-comment-field-text-area-label/
//
function wpsites_modify_comment_form_text_area($arg) {
 $arg['comment_field'] = '<p class="comment-form-comment"><label for="comment">' . _x( 'Your feedback is appreciated!', 'noun' ) . '</label><textarea id="comment" name="comment" cols="55" rows="7" aria-required="true"></textarea></p>';
 return $arg;
}
add_filter('comment_form_defaults', 'wpsites_modify_comment_form_text_area');
// Adjust post meta in entry header AND change comments text in comments button
// http://wpspeak.com/remove-post-date-in-genesis-framework/ 
//
add_filter( 'genesis_post_info', 'post_info_filter' );
function post_info_filter($post_info) {
    $post_info = '[post_date] By [post_author_posts_link] [post_comments zero="Add a Comment" one="1 Comment" more="% Comments"] [post_edit]';
	return $post_info;
}
// Thanks to Jo at http://www.jowaltham.com/customising-comment-date-genesis/
// In reply: Remove time and link inside the date field.
//
add_filter( 'genesis_show_comment_date', 'jmw_remove_comment_time_and_link' );
function jmw_remove_comment_time_and_link( $comment_date ) {
 printf( '<p %s>', genesis_attr( 'comment-meta' ) );
 printf( '<time %s>', genesis_attr( 'comment-time' ) );
 echo    esc_html( get_comment_date() );
 echo    '</time></p>';
 // Return false so that the parent function doesn't also output the comment date and time
 return false;
}
// Customize the submit button text in comments https://gist.github.com/studiopress/5708140
//
add_filter( 'comment_form_defaults', 'sp_comment_submit_button' );
function sp_comment_submit_button( $defaults ) {
 $defaults['label_submit'] = __( 'Submit', 'custom' );
 return $defaults;
}

Author box and Gravatar From https://briangardner.com/code/ 

Add a h1 tag around the authors name.

//* Change the author box title
add_filter( 'genesis_author_box_title', 'bg_custom_author_box__title' );
function bg_custom_author_box__title() {
	return 'Paal Joachim Romdahl';
}

//* Customize the Gravatar size in the author box
add_filter( 'genesis_author_box_gravatar_size', 'bg_author_box_gravatar' );
function bg_author_box_gravatar( $size ) {
	return '105';
}

Resources:

https://wpsites.net/web-design/customize-comment-field-text-area-label/
https://wpsites.net/wordpress-tips/show-posts-with-most-comments-first-on-your-home-page/
https://wpsites.net/wordpress-tips/show-posts-with-most-comments-first-on-your-home-page/
https://wpsites.net/genesis-tutorials/genesis-add-comment-bubble-with-counter-to-entry-meta/

Share the article:

Leave a Reply

Your email address will not be published.

2 × 2 =