Remove avatars from comments

When an article has many comments, the avatars within those comments can represent a large percentage of your overall page size. You can drastically decrease the load time on your popular articles by removing the avatars.

You could go to Settings > Discussion to disable avatars sitewide, but this will also remove author avatars as well.

If you are using avatars in an author box above or below the post, you should use the following code to remove only the avatars in the comments area. Place this in your theme’s functions.php file or a core functionality plugin.

/**
 * Remove avatars from comment list
 * @link https://www.billerickson.net/remove-avatars-from-comments/
 */
function be_remove_avatars_from_comments( $avatar ) {
	global $in_comment_loop;
	return $in_comment_loop ? '' : $avatar;
}
add_filter( 'get_avatar', 'be_remove_avatars_from_comments' );

For more performance recommendations, see 10 ways to speed up your WordPress website

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk

Reader Interactions

Comments

  1. Álvaro says

    “You can drastically increase the load time on your popular articles by removing the avatars.” I believe you mean “decrease the load time”. Right?

    Thanks for sharing.

Leave A Reply