How to change the default Gravatar for WordPress comments

How to change the default Gravatar for WordPress comments

Do you want to change the default Gravatar for WordPress comments? You want to use a custom image for the default Gravatar. You can make your comment section unique and branded. In this article, We will show you How to change the default Gravatar for WordPress comments.

Sometimes, We use code but  can not load the avatar. It’s a major issue. Because, We do not try to understand  How to work the default Gravatar. Let’s know about default gravatar.

What is default Gravatar:

Gravatar is a web service owned by WordPress Co-Founder Matt Mullenweg. His company is named Automatics. It’s an offer to create a profile under email addresses. The avatar is attached with an email address.

Avatar image is displayed on WordPress blog where users leave a comment. WordPress has built-in support for gravatar.  

When users don’t have a gravatar profile, Then Gravatar automatically creates avatar images for comment users. We can set a default avatar for redeem comment users. Let’s change the default avatar in WordPress.

How to change default avatar in WordPress:

WordPress has in-built some avatar images. You can select one of them. Just go Settings > Discussion scroll down and you can see the Default Avatar option.

How to change the default Gravatar for WordPress comments

But if you don’t want to, use one of them. You can use your own custom image for default avatar in WordPress. Just follow the step:

  1. Upload your avatar image to the Media Library and copy the URL.
 How to change the default Gravatar for WordPress comments

2. Use this code on your function.php

function wpknifer_custom_gravatar ($avatar_defaults) {
$avatar = 'https://wpknifer.com/wp-content/uploads/2021/06/wpk-avater.jpg';
$avatar_defaults[$avatar] = "WPKnifer Gravatar";
return $avatar_defaults;
}
add_filter( 'avatar_defaults', 'wpknifer_custom_gravatar' );

Remember, Please replace your own uploaded image link. And You can not use local images, You need to use an image link.

If you use the code properly you can see a new avatar image was created.  Now you can select this image as a default avatar.

FAQs:

Why my custom gravatar not showing up on WordPress

Yah , This is the most common issue. Because, Most of developer want to use their own internal image location. They use get_template_directory_uri() or get_theme_file_uri(). But This not work on gravatar images.  You need to use a direct link of the image. I think you can solve this issue now. 

Conclusion: 

Each theme developer likes to use own avatar image by default. You can do it with the WP User Avatar plugin. But for simple work you can do it with our custom code. 

We hope this article will help you. We think you know now, How to change the default Gravatar for WordPress comments. If you have any problem with WordPress comment avatar. Feel free to comment below.

See More:

Create a Portfolio Gallery in WordPress

How to get the next and previous post link in WordPress

5 comments

  1. Nice post. I learn something more challenging on different blogs everyday. It will always be stimulating to read content from other writers and practice a little something from their store. I’d prefer to use some with the content on my blog whether you don’t mind. Natually I’ll give you a link on your web blog. Thanks for sharing.

  2. Magnificent items from you, man. I’ve keep in mind your stuff previous to and you are simply extremely fantastic. I actually like what you’ve obtained here, certainly like what you are saying and the way through which you assert it. You are making it entertaining and you continue to take care of to stay it smart. I cant wait to learn far more from you. That is really a terrific website.

  3. I’m now not positive where you are getting your information, but great topic. I needs to spend a while learning more or working out more. Thank you for magnificent info I was on the lookout for this info for my mission.

Leave a Reply

Your email address will not be published. Required fields are marked *