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!

Siteground Hosting
Does WPLift load fast for you? That’s because we use Siteground for hosting, WPLift readers can click here to get up to 60% off hosting for your site.

Disclosure: This page may contain affiliate links for which we will receive compensation if a purchase is made.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Leave Yours +


  1. Ammar Kasbati

    bookmarked it… will surely use it for my personal blog…

  2. nice info..thanks for sharing….

  3. Anonymous

    This is very simple, but thanks for the code

  4. Anonymous

    This is very simple, but thanks for the code

  • Comments are Closed

Our Sponsors


Join our Newsletter to Receive 6 Free WordPress Themes

We will also send you our weekly Newsletter packed with the Latest WordPress Content.

We will look after your email & Never Spam!

You have Successfully Subscribed!