Add a Custom Gravatar to your WordPress Theme + Freebies

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.


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

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.



Oliver Dale is the founder of Kooc Media, An Internet Company based in Manchester, UK. I founded WPLift and ThemeFurnace, find out more on my Personal Blog. Thanks!

Related Articles


4 thoughts on “Add a Custom Gravatar to your WordPress Theme + Freebies”

Comments are closed.


Create Your Own

Building beautiful WordPress websites has never been easier. Explore the visual drag & drop Theme Builder that does it all, and works on any theme. Coding skills needed: none.