How to Change the Default Gravatar on WordPress

130

Do you want to change the default Gravatar on your WordPress site? By adding your own default gravatar image, you can make your comments section branded. In this article, we will show you how to change the default gravatar in WordPress and replace it with your own custom default gravatar image.

How to change default gravatar image in WordPress

What is Default Gravatar and Why Change it?

Gravatar is a web service created and run by WordPress co-founder Matt Mullenweg’s company called Automattic. It allows anyone to create a profile and associate avatar images to their email addresses.

This avatar image is then displayed on all WordPress blogs where users leave comments or write blog posts. For more details see our guide on What is gravatar and why you should start using it right away.

All WordPress sites come with built-in support for gravatars and automatically show users’ avatars when they write posts or leave comments.

However, if a user doesn’t have a gravatar image, then WordPress automatically shows the default gravatar image. The default option is to show an image called mystery man. It looks like this:

Default mystery person gravatar in WordPress

If you don’t want to use the mystery man as default image, then you can change it to your own branded image.

Having said that, let’s see how you can change the default gravatar image on your WordPress site, so you can use a custom default gravatar image.

Changing Default Gravatar Image in WordPress

First, you need to visit Settings » Discussion page and scroll down to Avatars section. This is where you can configure and change gravatar settings on your WordPress site.

Gravatar settings in WordPress

You will notice that there are a few choices available under the default avatar option. These avatars are used when a user does not have a gravatar associated with their email address.

Out of the box WordPress uses the mystery person icon as the default gravatar. You can change that to blank or gravatar logo.

There are few other options available as well. These are automatically generated images in different designs. These images use comment author’s name or email address to mathematically generate a unique gravatar image.

Don’t forget to click on the save changes button after changing your default gravatar.

Using Custom Default Gravatar Image in WordPress

WordPress also allows you to use your own default gravatar images. Here is how you can easily add your own custom default gravatar image in WordPress.

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.

Next, you need to upload this image to your WordPress site. Head over to Media » Add New and upload your custom default gravatar image.

Upload and edit custom default gravatar image

After the image is uploaded, you need to click on the Edit link next to the image.

WordPress will now open your image for editing. You need to just copy the image file URL and paste it in a plain text editor like Notepad.

Copy file URL

Now you need to add some code to your WordPress site. If you haven’t done this before, then please take a look at our guide on how to copy paste code in WordPress.

Add the following code to your theme’s functions.php file or a site-specific plugin.

  add_filter( 'avatar_defaults', 'wpb_new_gravatar' );  function wpb_new_gravatar ($avatar_defaults) {  $myavatar = 'http://example.com/wp-content/uploads/2017/01/wpb-default-gravatar.png';  $avatar_defaults[$myavatar] = "Default Gravatar";  return $avatar_defaults;  }  

Don’t forget to replace $myavatar value to the URL of the custom gravatar image you uploaded earlier.

You can now visit Settings » Discussion page and you will notice your custom default avatar added to default avatar choices.

Custom default gravatar image

Select your custom default avatar image, and then click on the save changes button.

WordPress will now use your image for users who don’t have their gravatar associated with their email addresses.

Custom default avatar image in WordPress

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 set custom avatars for users in WordPress.

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.