How To Change Default Gravatar On WordPress

WordPress, let’s you add post comments for your blog post. The post comments will display the user avatar, ie, Gravatar image before the comment by default. If the user has the email associated with Gravatar then, the Gravatar image will get displayed as set. If not then, the Gravatar image will be shown as set in Discussion setting via your WordPress dashboard. But what if you want to modify that to your liking, ie, change default Gravatar image to custom image. Is it really possible? Yes it is possible and here we will learn about how to do it for your site.

What is default Gravatar image set in WordPress?

WordPress let’s user to add comments to the blog posts created in your site. It will display the Gravatar image of the user if they have created their Gravatar profile and left the email as set in their Gravatar profile.

But what if the user leaving the comments does not have Gravatar profiles? Well for that, the default image show is of Mystery Person. You can see the same as in the below screenshot:

However, if you do not like it then, you can change to other images as needed for your site. You can also change that to the custom image of your own, for eg: you can use company logo in it too.

But first of all, let’s learn about how to change that to custom image provided default via WordPress, shall we?

How to change default Gravatar image to other images set in WordPress?

For changing the default Gravatar set for user comments used in WordPress, ie, Mystery Man to other custom image, you can visit Settings->Discussion section via your WordPress dashboard. Now after going to that section, goto Default Avatar section. There, you will see different options for Gravatar image to set to. There, choose the required option and the default Gravatar image is changed for comments.

Here, we will set the default avatar image to Gravatar Logo on that option and see the result. First of all, let’s see the Default Avatar set to Gravatar Logo via the discussion section, which is below:

Now, as you can see the setting is set to Gravatar Logo. Now, since it is changed, you will see the previous output of the comments as below changing the image to that one chosen:

You can see that the same comment with same commenter image is changed to the selected one’s in the Discussion setting.

Now, what if you want to change the default image to the custom image of your own? Is it really doable? Yes it is and let’s move ahead about integrating it for your site.

How to use custom image to change default Gravatar image in WordPress?

For this, first of all, you need to know about what to change, ie, modify the default avatar in WordPress. Well for this, you need to know that in which filter hook you need to hook custom function to. Well it is  avatar_defaults filter hook.

Now after knowing the filter hook, you need to edit the functions.php file of the theme. Just open it up and add the below PHP code in that file:

In the above code, you need to modify the $custom_avatar to the exact image url which you want to use for.

After that, when you visit Settings->Reading section, you will find new Gravatar option to choose from for default avatar. You can see the result as below:

Now, you need to choose the last one option available from there and when you see the comments section with users having no Gravatar image associated, you will see the result as below:

You can see as in result screenshot above, that the default Gravatar image is changed as you have selected.

You may also want to read:

  1. Disable Comments Automatically After Specific Number Of Days
  2. How To Disable Comments In WordPress?
  3. How To Filter WordPress Content
  4. Make Your Theme WooCommerce Plugin Compatible
  5. Remove WordPress Admin Bar Except For Administrator

Conclusion

If you have successfully followed this tutorial and have became successfully able on change default Gravatar image for your site then, we can assume that you are now more familiar on this than before. But, if you are still confused about how to do it and want more help on this then do drop the comment below in the comment box and we will follow it up.

Post navigation

Bishal Napit

Bishal Napit is a WordPress theme developer from Tansen, Palpa, with a passion to learn more on WordPress.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.