How-to Change the Default Gravatar in WordPress

A gravatar is a globally recognized avatar, created by Tom Preston-Werner and is owned by Automattic, the creators of WordPress. A gravatar is created by a user assigning a avatar to their e-mail address. So, when the user posts a comment on a blog, their avatar will appear beside or near their comment. If they don’t have an gravatar, a default avatar will be displayed, which in WordPress is called the mystery man. The mystery man avatar looks something like this:Mystery Man Avatar

Now the mystery man avatar leaves nothing to be desired, it’s plain and doesn’t help with branding. So, I’m going to show you two (2) different ways to change the default avatar for your WordPress installation.

Use the Pre-Made WordPress Avatars

WordPress comes with seven (7) pre-made default avatars, which includes the mystery man avatar. To change the default avatar to one of these pre-made default avatars, go to your WordPress login page and login. Next, move your mouse over the “Settings” link on the left sidebar menu. A dropdown menu will appear. Click on “Discussion,” which should be the fourth option in the dropdown menu. You’ll arrive on a page entitled “Discussion Settings.” Scroll right to the bottom of the page. You’ll see an option called “Default Avatar.” This is where you can change the default avatar to something else that is pre-made.

To select another avatar, simply click on the radio button (circle button) next to the avatar and then press “Save Changes” below.

Create Your Own Default Avatar

You can create and use your own default avatar if the pre-made ones don’t meet your taste. Plus, creating and using your own default avatar can help your brand.

To add your default avatar in WordPress, open your theme’s functions.php file and add the following.

 function new_avatar ($avatar_defaults) { $my_avatar = get_bloginfo('template_directory') . '/images/my-avatar.png'; $avatar_defaults[$my_avatar] = "Avatar Name"; return $avatar_defaults; } add_filter( 'avatar_defaults', 'new_avatar' );

Now let’s discuss the two options you can change. The first is the location of your avatar. This can be found on line two (2). I’ve set it to the images directory of your theme. The file name for the avatar is my-avatar.png. If your avatar is hosted elsewhere like in a CDN, you can change line two (2) to something like this:

$my_avatar = '';

Also, make sure your avatar is at least 80 pixels by 80 pixels.

The next option is on line three (3), which is where you can set the name of your avatar, which I’ve auto set to Avatar Name.

Once you’ve uploaded the avatar and added the above code snippet to your theme’s functions.php, you’ll have to login to WordPress and set the default avatar to your avatar. So, login to WordPress and move your mouse over the “Settings” link on the left sidebar menu. A dropdown menu will appear. Click on “Discussion,” which should be the fourth option. Scroll to the bottom of the page until you see the “Default Avatar” option. Your avatar should be added to the bottom of the list. Click on the radio bottom (circle bottom) next your avatar and click on “Save Changes” below. You’re done!