EN / ZH
Customizing the Default WordPress Comment Avatar

For commenters who haven’t set up a Gravatar avatar, WordPress displays one of the default avatars you’ve configured in the backend — options like Mystery Person, Blank, or the default Gravatar logo.

But these avatars aren’t particularly attractive or engaging. Think about it this way: if you visit a blog and notice that all the commenters’ avatars are auto-generated mystery persons, little monsters, or retro icons — would you still feel enthusiastic about reading the articles? Have you ever considered designing or finding a custom default avatar that matches your blog’s personality? Alright, I won’t keep you in suspense any longer. Let me walk you through how to customize the default WordPress comment avatar without using a plugin.

The method is quite simple — just add the following code to your active theme’s functions.php file:

<?php
// Make a new default gravatar available on the dashboard
function newgravatar ($avatar_defaults) {
$myavatar = get_bloginfo('template_directory') . '/images/tweaker.jpg';
$avatar_defaults[$myavatar] = "Tweaker";
return $avatar_defaults;
}
add_filter( 'avatar_defaults', 'newgravatar' );
?>

In the code above, /images/tweaker.jpg is the relative path to your custom default avatar. You can modify the image path as needed. I recommend placing the avatar image in the “images” folder of your active theme.