Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Change the Default Gravatar on WordPress (Easy Tutorial)

Do you want to change the default Gravatar on your WordPress site?

If a visitor doesn’t have a Gravatar, then WordPress will show the same grey ‘mystery person’ by default. By replacing this stock picture with an image of your choice, you can brand your comments section and make it stand out.

In this article, we will show you how to change the default Gravatar on WordPress.

How to change the default Gravatar on WordPress

What Is a Default Gravatar and Why Change it?

Gravatar stands for Globally Recognized Avatar. It’s a web service that allows people to create a profile and associate avatar images with their email address.

All WordPress sites have built-in support for Gravatars and will automatically show the user’s avatar when they write posts on a multi-author WordPress blog or leave comments.

If a user doesn’t have a Gravatar, then WordPress will show a default Gravatar instead. For most WordPress websites, this is a grey mystery person.

The default Gravatar in WordPress

You can change this default Gravatar to any other picture of your choosing. For example, you might use an image that represents your company, such as your website logo. This can help reinforce your branding.

Having said that, let’s see how you can change the default Gravatar image on your WordPress website or blog. Simply use the quick links to jump straight to the method you want to use.

Method 1: Use a Different Built-in WordPress Gravatar (Quick and Easy)

WordPress comes with a few different default Gravatars that you can use. Using the defaults is the quickest way to change the mystery person Gravatar, although these images won’t be unique to your website or brand.

To look at the different default Gravatars, you need to go to Settings » Discussion.

Changing the default Gravatars in WordPress

Under ‘Default Avatar,’ you will see all the different built-in avatars that WordPress can use when there’s no Gravatar linked to the person’s email address.

Out of the box, WordPress uses the mystery person as its default, but you can use any other image in this section.

The built-in WordPress Gravatars

Simply click on the radio button next to the image you want to use on your WordPress blog. Then, scroll to the bottom of the screen and click on ‘Save Changes.’

Method 2: Using a Code Snippet (Create a Completely Custom Gravatar)

WordPress also allows you to upload your own default Gravatar. This is the best way to make your comment section stand out from the competition.

First, you need to create an image that you want to use as the default Gravatar. This image should be a square, like 250×250 pixels.

You can use a stock photo, make your own custom logo, or even create a new Gravatar image using web design software such as Canva.

With that done, you need to upload the image to your WordPress site by going to Media » Add New. Here, you can either choose an image from the WordPress media library or upload a new file from your computer.

How to upload a custom default Gravatar in WordPress

After choosing an image, go ahead and click on the ‘Edit’ link next to it.

WordPress will now open the file for editing. On this screen, scroll to the ‘File URL’ section.

Uploading a default WordPress Gravatar

Make a note of this URL, as you will be needing it in the next step.

Now you need to add some code to your WordPress site. Often, tutorials will ask you to add custom snippets to your theme’s functions.php file. However, we don’t recommend this because even a small mistake in your code can cause a number of common WordPress errors or completely break your website.

That’s why we recommend using WPCode. It is the easiest and safest way to add custom code in WordPress without having to edit any core WordPress files.

The first thing you need to do is install and activate the free WPCode plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.

Upon activation, go to Code Snippets » Add Snippet in your WordPress dashboard.

How to add a custom avatar snippet to your WordPress website

Here, you will see all the different snippets you can add to your WordPress website. These include snippets that allow you to completely disable comments in WordPress, upload SVG files to your site, and more.

Since we are adding a custom snippet, hover your mouse over ‘Add Your Custom Code,’ and then click ‘Use snippet.’

Showing a custom avatar using code

To start, enter a title for the custom code snippet. This can be anything that helps you identify the snippet in your WordPress dashboard.

After that, you need to open the ‘Code Type’ dropdown and click on ‘PHP Snippet.’

How to add a PHP snippet in WordPress

Once you have done that, simply paste the following snippet into the code editor:

add_filter( 'avatar_defaults', 'wpb_new_gravatar' );
function wpb_new_gravatar ($avatar_defaults) {
$myavatar = '';
$avatar_defaults[$myavatar] = "Default Gravatar";
return $avatar_defaults;

Don’t forget to replace the URL with a link to the image you want to use as the default WordPress Gravatar.

Below the code box, you will see insertion options. If it isn’t already selected, then choose the ‘Auto Insert’ method so that the snippet will be automatically inserted and executed across your entire site.

After that, open the ‘Location’ dropdown and click on ‘Run Everywhere.’

How to run PHP gravatar code across your website

Once you have done that, you need to scroll to the top of the screen and click on the ‘Inactive’ toggle so that it changes to ‘Active’ instead.

Finally, go ahead and click on ‘Save’ to make the Gravatar snippet live.

How to activate the gravatar code snippet

To start using this Gravatar, go to the Settings » Discussion page.

In the ‘Default Avatar’ section, select the new ‘Default Gravatar’ option.

How to change the default Gravatar in WordPress

After that, make sure you click on ‘Save Changes’ to store your settings.

Now if you visit your website you’ll see the new default Gravatar image live.

An example of a custom defualt Gravatar, on a WordPress website

We hope this article helped you learn how to change the default Gravatar on WordPress. You may also want to see our guide on how to allow user registration on your WordPress site, or our expert picks for the best WordPress membership plugins.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

117 CommentsLeave a Reply

  1. Hi guys,

    Wonderful tutorial, you saved me from a big headache! Keep up the great work!!!

    Best regards,


    • We do not have a recommended method at the moment but if that changes we will be sure to share.


  2. This worked like a charm. Thanks!! Is there a way to have multiple default gravatar which can be assigned randomly to users ?

    • You would need a plugin for a feature like that, if we find a plugin we would recommend we will certainly share.


  3. This is not working. WordPress does not allow to use local images. Please review your tutorial and update it accordingly.

    • If our method was not able to assist, you would likely want to reach out to your theme’s support to ensure there isn’t a theme-specific setting preventing the change.


  4. Okay, I found an easier solution for everyone that works well: just install the “WP User Avatar” plugin. Works like a charm and you don’t have to do anything with coding!

  5. This is great, thanks! I followed this by installing the plugin to add the code and then adding my 250×250 picture. It worked great, but now if anyone comments on my site, my picture, not theirs, shows up next to their name. My picture shows up everywhere and no one else’s. Any idea why?

    Thank you. :-)

  6. Thank you for this post!! I use All in one SEO and could never get it to work. Your post provided a good map and work around. However I am still getting 12 error msgs? are they possible related?

    • It would depend on the specific errors. If you reach out to the plugin’s support they should be able to assist.


  7. Thank you for this post! But, what if I just want to change my personal avatar without using gravatar?

  8. I want an option where the user can upload an image as per their requirements. What should I do for that ?

  9. ty – its worked for me – but now default avatar loded from other site – how i can define that this image loaded from my host?

    • You’re likely using the Jetpack plugin and using their option to load images from their server. You can go into Jetpack’s settings to disable this function.


        • If you mean you want your gravatar image to be loaded from your site when it is added to other sites, that is not an option at the moment.

  10. Hey so I have sort of a peculiar yet distinct task that I need help with. My client has a blog on WordPress but then they post their blog to Twitter, next to the article is a gray blank avatar. She had requested that I find a way to put some sort of image in place of this but I am not sure how to go about doing this. I know she uses a Gravatar for the comment section but this instance is a bit different. Any advice on what I can do?

  11. Hello, the code works well, but I made some changes to my newly added avatar picture and I still see the first version when I refresh the page.

    Looking at the url of the picture it automatically added “” at the beginning (I don’t have jetpack or any cache plugins).

    I guess I can just change the name of my picture and update the code, but is it a way to get ride of wp cache?

  12. I have no problem changing the image on my gravatar but I cannot seem to change the words. Even though I select edit and rewrite them, the change doesn’t appear on my wordpress site. What am I doing wrong?

  13. Thank you, thank you, thank you! I’ve looked everywhere on how to change the default avatar and you were the only ones who simple explained it and displayed how! Sometimes finding the answer in the haystack of information can be just mind blowing. You rock!

  14. Hello, I’ve tried this in my child’s theme function and it just will not work. The image in the discussion settings and on the front-end appear broken. When I right click to view the path it displays:

    It affixes the before the link. Even when I tried to connect directly to the child theme stylesheet directory and pickup from the folder, ‘images/chicken_avatar.png’, it still affixed the

    Any ideas how to fix this? Thank you.

    • Hey Joy,

      We tested it again with a child theme and it worked as expected. We are not sure what may be causing the issue. You can follow the instructions again. Make sure you add the full image URL in the code.


      • It Still Shows Whwn Going to the Image Location, but I Changed the URL Code to (‘/custom-gravatar/mh-profile-photo-default.png’), Instead of ‘’). In Settings > Discussion It Shows My Admin Photo as the Default User Gravatar, but On User Profiles, It Views Properly! :–)

  15. Hello.

    The code worked perfectly fine for me. But this arises another problem:

    Same gravatar appears when everyone else including visitor comments on my blog.

    How to solve this?

  16. Hi, i added and sucesfully saved input(type = url) for each user profile, on ly localhost installation.
    I’m trying to change original code from WP Codex wesbsite:

    add_filter( ‘avatar_defaults’, ‘new_default_avatar’ );

    function new_default_avatar ( $avatar_defaults ) {
    //Set the URL where the image file for your avatar is located
    $new_avatar_url = get_bloginfo( ‘template_directory’ ) . ‘/images/new_default_avatar.png’;
    //Set the text that will appear to the right of your avatar in Settings>>Discussion
    $avatar_defaults[$new_avatar_url] = ‘Your New Default Avatar’;
    return $avatar_defaults;

    To something that will replace default avatar url foreach user with value from custom input field(if its not empty), any help?
    I know there are plugins that allows subsciribers to upload gravatar images, but i don’t want to allow them doing that, i want to give them a chance to put url to their own images

  17. THANK YOU!

    Actually I’ve been looking for this solution for my blog for 3 months!
    Thanks again!

    Claire xo

  18. I have the Gravatar set up in WordPress, but when the e-mail goes out to my followers for my blog, the mystery man is there. Looks really bad at the top of my e-mail. Any suggestions?


  19. Here are two folders of images in Cpanel.
    1. /public_html/wp-includes/images
    2. /public_html/wp-content/themes/divi/images

    In which folder where I upload the image.

  20. I’m looking for a plugin, or SIMPLE code solution that will allow me to create a number of ‘default’ gravatar/avatar images that are color coded based on the member’s gender/orientation. Obvious ones like blue for male, pink for female, but I’ll likely add lavender for transgender and possibly others. Basically, the decision about the ‘default’ avatar that appears for the member (until they upload an image) would at least let people browsing the site know if the person they see posting (or online) is male / female / transgender / etc.. Any ideas?

  21. Is there code to force the default avatar to be blank? I have it set to blank in the WP settings, but it’s still showing up as mystery man. Is there code to either delete mystery man entirely so it’s not even an option. Or to make sure it’s blank and not mystery man? Thanks!

  22. How would one go about rotating a set of images in that Gravatar thumbnail spot? Meaning: if I had 5 different images, to have them randomly appear for users without Gravatars, so there was a variation of the 5?

  23. If anyone is facing issues with child themes, just use:

    $myavatar = get_stylesheet_directory_uri().’/img/favicon.png’;

    It works.

  24. Wow – found this post 2 years after my first post and got it working this time :)
    Thanks WP Beginner

    • Goto Gravatar website and sign in with WordPress. Then you can upload your avatar and tie it to one or more of your emails.

  25. Thank you so much for these instructions. For some reason, things were wonky when I used a .png file, but a gif worked easy peasy!

  26. I am having the same issue as Keely. I am using a child theme so get_bloginfo does not work. When I check the URL of the broken image it displays the path to the parent theme. Is there a way to get this to work with a child theme?

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.