Have you ever wanted to replace the “Blank Man” or the default Gravatar avatar in the comments section of your WordPress site with your own branded avatar? Here’s the code you’ll need to put in your theme’s functions.php file to get this done:
add_filter( 'avatar_defaults', 'newgravatar' );
function newgravatar ($avatar_defaults) {
$myavatar = get_bloginfo('template_directory') . '/images/avatarimage.jpg';
$avatar_defaults[$myavatar] = "Custom Brand Name Here";
return $avatar_defaults;
}
Of course you should change the “avatarimage.jpg” to whatever you would like and the “Custom Brand Name Here” to whatever you want to show up in the Avatar section on the Discussions page.
The only thing left to do is to switch your avatar settings on the Discussions page. This will allow anyone with avatars setup at different places like Gravatar to show their own avatar…however if a user doesn’t have one, then the code above will set theirs to the default until they create their own.
Hope this helps!
Here is a screen shot from one of our clients setup, The Handmade Home. This is how it should show up on the discussions page.














You know there’s a plug-in that does this, right? It’s foolproof, actually. I tried doing it without the plugin and got errors. But the plug-in was smooth sailing. I think it was called Add New Default Avatar. Search for it in the add new plugin screen of the WP dashboard.