Skip to main content

How to Change Default Gravatar on WordPress

Implementation of Gravatar is an uprising trend that is being seen on many WordPress Blogs. More and more blogs are following the trend by incorporating the gravatar. Not only bloggers, but theme designers are also focusing on making the best comment box for their WordPress themes and implementing gravatar with creativity.

While bloggers may know about gravatar and have an account, there are other users who don’t have a personal gravatar, so when they post a comment on a blog, a mystery man takes over their gravatar. You probably have seen it on many blogs, on a gray background a white guy. In this article we share a way to have a custom gravatar for your blog users which you can incorporate in your blog.

As you can see in our comment box, when a user who does not have a gravatar account comments, our wpbeginner logo shows up. You can do the same now. First thing you need to make sure is that your theme have gravatar enabled.

1. Open your functions.php file which is located in your themes folder.

2. Then paste the following code in there

add_filter( ‘avatar_defaults’, ‘newgravatar’ );

function newgravatar ($avatar_defaults) {
$myavatar = get_bloginfo(‘template_directory’) . ‘/images/gravataricon.gif’;
$avatar_defaults[$myavatar] = “Sitesao”;
return $avatar_defaults;
}

You need to understand the variables in the code above.

‘/images/gravataricon.gif’ is the location of the image file. It must be saved under the theme folder that you are using.

Change Sitesao to the name that you want to give your Gravatar and you should be all set.

3. Upload this file

4. Login to your WordPress Admin Panel and click on Settings > Discussion

 

Your gravatar now show up like the picture above displays. Select it and save changes, and you are all set.

Now you should be able to change your gravatar in no time.

 

Related News

Create a sticky post or private post in WordPress

Sometimes, there is an important post that you may want to keep it at top...

How to Add Infinite Scroll to your WordPress Blog

If you want to reduce number of actions that your readers have to take to read...

How to Install Google Analytics in WordPress

Bet that you are not writing blog on your website for no one. It's important...

Leave a reply