WPLift is supported by its audience. When you purchase through links on our site, we may earn an affiliate commission.

Add a Custom Gravatar to your WordPress Theme + Freebies

Last Updated on June 14th, 2019

Published on August 17th, 2011


Share This Article

Gravatar is a service from Automattic which stands for “Globally Recognized Avatar”, you can signup on their site and upload an avatar for yourself and then when you use the same email when commenting on WordPress blogs it will show up. When a user comments and they haven’t signed up for their own Gravatar, WordPress has a number of default ones built-in that it will display instead. You can choose which is shown, in your WordPress admin, go to “Settings” > “Discussion” and scroll down and you will see the options :

Most blogs just use the default “Mystery Man” – in this post I will show you some code you use in your theme so you can add your own custom option.

Open your theme’s functions.php file and paste the following code :

add_filter( ‘avatar_defaults’, ‘newgravatar’ );

function newgravatar ($avatar_defaults) {
$myavatar = get_bloginfo(‘template_directory’) . ‘/images/GRAVATARHERE.png’;
$avatar_defaults[$myavatar] = "NAMEHERE";
return $avatar_defaults;

There are two options you can change, the first is the path and file name of your avatar image, this points to the images folder in your theme directory and the image name is “GRAVATARHERE.png” – change to what you like.


The other piece of code to change is “NAMEHERE” – this is what the gravatar is called in the WordPress discussion options screen. Change it to what you like.


Article Continues Below

And that’s it, you can now visit your discussion settings in the WordPress admin and you will see your new option, choose it and hit Save and it will now appear in your theme.

Some Gravatars for you to Download

I have put together an avatar pack for you to use in your themes for free, the icons were found on FindIcons.com.

The Zip file contains 24 icons and a .PSD file if you wish to modify them or the background color.

Download Gravatars (1.21MB) » Get Hosting »


These Avatars are released under the GPL 2 License which means they are free to download and use for yourself or clients and modify it anyway you see fit.

Stay informed on WordPress

Every Friday you’ll receive news, tutorials, reviews, and great deals from the WordPress space.

Invalid email address
Oliver Dale is the founder of Kooc Media, An Internet Company based in Manchester, UK. I founded WPLift in 2010.