Add Custom Default Avatar in your WordPress Blog(without plugin)

How to add custom default avatar WordPress? How to Change the Default Gravatar on WordPress? How to Set Custom Avatars for Users in WordPress? Replace WordPress default avatar?

I believe you land on this page looking for answers in one of those queries.

And yes, you’re at the right place.

In this article, we will teach you on how to change the default Gravatar on your WordPress site without a plugin.

As much as possible, it is good to lessen the number of plugins in your website. We will just add a few lines of code in your theme’s functions.

But first, let me tell you why you should replace WordPress default avatar on your blog.

  1. The default avatars are ‘ugly’.
  2. You want to brand your comment section
  3. Design

For example, this comment of kanaram kasniyan and Abdulrazaq Olatunji on How Google Adsense Work? How much can you earn from it? article.

Add Custom Default Avatar in your WordPress Blog

As you can see, the user has a “mystery person” avatar. Will it be good to change it?

Are there any other avatars other than mystery person image?

Yes, there is. If you go to your WordPress dashboard, then Settings and click Discussion, you will see different kinds of avatar to choose from.

WordPress Default Avatars

 

As you can see, I don’t have a choice either. Better be it at mystery person image.

But there’s a solution to add custom default avatar on top of other default avatars on your WordPress blog. Just follow the step by step guide below on how to change the default Gravatar on WordPress.

Let’s get it on!

Add Custom Default Avatar in your WordPress Blog

Here’s the good thing.

WordPress allows us to change and add custom default avatar in our WordPress site. The first thing you need to do is to create an image at least 250px x 250px in size and upload it to your media library.

In my case, I use my blog’s icon to use it as my custom default avatar.

Custom Avatar Black

 

After you choose what to use as custom avatar, you need to upload it to your media library.

In your WordPress dashboard,  go to Media then click Add new.

Add New Media

 

You can drag and drop your avatars or you can manually select it. Now we need the full URL of the image, click Edit.

Upload your new custom avatar

 

Now copy the File URL and paste it on Notepad. We will need it later.

Copy the File URL of the custom avatar

After that, go to Appearance then click Editor.

Go to Appearance Editor

 

In this area, you’ll have access to customize your site using your theme’s functions,php file. Click on Theme Functions on your right and copy and paste this code:

add_filter( 'avatar_defaults', 'bt_custom_gravatar_black' );
function bt_custom_gravatar_black ($custom_avatar_black) {
$mycustomavatarblack = 'https://blogtrainee.com/wp-content/uploads/2017/05/BLOGTRAINEE-CUSTOM-AVATAR-BLACK.png';
$custom_avatar_black[$mycustomavatarblack] = "Custom Gravatar Black";
return $custom_avatar_black;
}

What you need to do is to replace the URL in $mycustomavatarblack with the File URL of your own custom gravatar which you have pasted on Notepad earlier.

After that, click Update File. And finally, you can visit Settings > Discussion and choose the default avatar with your custom avatar.

Replaced WordPress default Avatar

Now see it in action.

How to Set Custom Avatars for Users in WordPress

 

You can also add multiple custom avatars using the code below BUT replace all in RED.

add_filter( 'avatar_defaults', 'bt_custom_gravatar_black' );
function bt_custom_gravatar_black ($custom_avatar_black) {
$mycustomavatarblack = 'https://blogtrainee.com/wp-content/uploads/2017/05/BLOGTRAINEE-CUSTOM-AVATAR-BLACK.png';
$custom_avatar_black[$mycustomavatarblack] = "Custom Gravatar Black";
return $custom_avatar_black;
}

Add Multiple Custom Avatars WordPress

 

I hope you enjoy this tutorial. How’s this tutorial goes to you? Did you successfully add custom default avatar in your WordPress site?

Let me know your feedback below.

About the author

Ronald

Ronald is the man behind blogtrainee.com. He loves to write tutorials on how to start a blog from scratch and to rank them and make money.

1 Comment

  • Thanks for sharing the great post
    Thanks for providing such a good information.
    Your Article is impressive and very informative.

Leave a Comment