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

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

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.

Conclusion

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:

A2 Hosting
NZ$3.12 /mo
Starting price
Visit A2 Hosting
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.0
  • Features
    4.5
  • Reliability
    4.8
  • Pricing
    4.0
IONOS
NZ$1.60 /mo
Starting price
Visit IONOS
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.0
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.3
Webdock
NZ$1.52 /mo
Starting price
Visit Webdock
Rating based on expert review
  • User Friendly
    3.8
  • Support
    4.5
  • Features
    4.5
  • Reliability
    4.3
  • Pricing
    4.3

How to Add Custom Code to Header and Footer Areas of a WordPress Website

The tutorial will have two methods of adding the custom code to the header and f
less than a minute
Bruno Mirchevski
Bruno Mirchevski
Hosting Expert

How to Secure the .htaccess File from Unauthorized Access

This guide will help you add one more security layer to your website by protecti
less than a minute
Idan Cohen
Idan Cohen
Marketing Expert

How to Disable PHP Execution to Improve Website's Security Using cPanel

This how-to guide will explain about restricting others from executing any malic
less than a minute
Max Ostryzhko
Max Ostryzhko
Senior Web Developer, HostAdvice CTO

How to Add Google Fonts to Your WordPress Website Without a Plugin

This is a how-to guide consisting of the code editing of the WordPress website t
less than a minute
Bruno Mirchevski
Bruno Mirchevski
Hosting Expert
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top