Remove Avatars from WordPress Blog Comments
By Aj Khandal | Published: | 1 min read
Avatars appear on every blog comment section on WordPress websites. These avatars are shown in the format of JPG. So it's obvious that they also affect website load time.
If a website has more than 50 comments, there's a chance of having more than 50 avatars in the comment area. This will decrease post speed significantly.
To remove these avatars, there is a direct option available in the WordPress admin area. Here are the steps to follow to disable avatars from the comment section:
Settings > Discussion — disable avatars sitewide.
But this will remove the author's avatar too. Here is another solution that keeps the author's avatar and removes only the avatars from the comments area.
Open the functions.php file of your current theme and add the following lines at the end of this file:
/**
* Remove avatars from comment list
* @link https://ajaykhandal.com/remove-avatars-from-wordpress-blog-comments/
*/
function aj_remove_avatars_from_comments( $avatar ) {
global $in_comment_loop;
return $in_comment_loop ? '' : $avatar;
}
add_filter( 'get_avatar', 'aj_remove_avatars_from_comments' );