Write Review

If you have searched for using a custom Gravatar, you must already know what Gravatar is. Even if you don't have any idea, let me walk you through.

You may have read many comments on different websites, with each comment, you see an avatar. Gravatar is a service founded by Matt Mullenweg - co-founder of WordPress. You can create your account and attach your image as an avatar, which will be used when you comment on a WordPress website.

If you don't have any Gravatar attached to your email address, WordPress displays a default image.

It means whenever a person without any Gravatar comments at your WordPress site, the default icon appears, which may not look good. So, you may wonder to use a custom Gravatar.

Well, in this tutorial, you're going to learn the simplest way to add a custom Gravatar using cPanel. You may be scratching your head to find an answer to your question if you need some coding skills.

You don't need to be a coder; I am going to provide you a code, all you need is copy, paste, and make a small change.

Use the functions.php to Add a Custom Gravatar

I hope you know that functions.php is one of the most important files of a WordPress theme. The file controls all the functions of a site.

First of all, you should know how to set a default Gravatar. Go to Settings>>Discussion and scroll down.

How to Add a Custom Gravatar to Your WordPress Site Using cPanel

There are different ways to edit such a file. You may be wondering to use the built-in editor from the admin area, but it may be hidden because of security reasons, so it's always good to use cPanel.

If you wish, you can use FTP, too!

Let me start the process.

Step 1:

As always, you need to open your web hosting account and login to cPanel. Find the file manager icon, which may reside under the Files' section.

How to Add a Custom Gravatar to Your WordPress Site Using cPanel

It's possible you may be confused because of a different cPanel layout. Every company tries to maintain its brand value by using the same color in cPanel.

Most of the leading WordPress web hosting services offer the direct file manager option.

Step 2:

By default, you may see the home directory, but you need to open public_html where all the content of your WordPress site is available.

How to Add a Custom Gravatar to Your WordPress Site Using cPanel

Go to the left-hand sidebar and find a link to public_html.

Step 3:

You can see many folders, open the wp-content folder in which all the plugins, themes, and media files of a WordPress site are present.

How to Add a Custom Gravatar to Your WordPress Site Using cPanel

Step 4:

As I have already mentioned, functions.php is a theme's file, so you need to open the themes' folder.

How to Add a Custom Gravatar to Your WordPress Site Using cPanel

Step 5:

Open your current theme, and you can find the functions.php file inside. Right-click to edit.

How to Add a Custom Gravatar to Your WordPress Site Using cPanel

As always, you can use the standard Edit option from the main navigation menu of cPanel.

Step 6:

Before you proceed further, go back to your WordPress dashboard and upload an image to your media library, which you want to use as a custom Gravatar.

How to Add a Custom Gravatar to Your WordPress Site Using cPanel

Note: The image should be square, like 400×400.

After uploading, click on the image to check its details and you can see its URL, copy it.

Step 7:

Get back to the code editor of functions.php. Copy the code shown below.

add_filter( 'avatar_defaults', 'custom_new_gravatar' );
functioncustom_new_gravatar ($avatar_defaults) {
$myavatar = 'http://example.com/wp-content/uploads/2018/11/new-default-gravatar.png';
$avatar_defaults[$myavatar] = "Custom Gravatar";
return $avatar_defaults;

Paste the code.

NOTE: The code consists of an image URL. You need to replace it with the URL you copied from your media library.

Click on the Save Changes button from the top-right corner, and you're all set. Now you can set the new Gravatar as your default Gravatar so that whenever someone without a Gravatar comments, this custom image appears.

I Hope You Have Understood the Concept of Adding a Custom Gravatar

Most of the people fret because the process includes a little bit of coding, but as you can see, you don't need to have any coding skills.

The replacement of the image URL solves the problem. Many websites use the custom Gravatar to match their brand value.


Do you think you can add a custom Gravatar? The above method explains everything you need to know. I understand, sometimes it's hard to edit a coding file for newbies, but there is nothing scary.

If you're afraid, it's essential to backup your WordPress site and its database.

Check out these top 3 WordPress hosting services:

Was this article helpful?