Created
April 27, 2016 07:06
-
-
Save bulbul84/49ff8a8660ae1e99a31e249577bf4956 to your computer and use it in GitHub Desktop.
How to changes default avatar from wordpress and add custom avatar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How to Change the Default Gravatar on WordPress | |
Last updated on June 21st, 2012 by Editorial Staff | |
Share This Article | |
Special WordPress Hosting offer for WPBeginner Readers | |
How to Change the 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. | |
Good Bye Mystery Man | |
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] = "WPBeginner"; | |
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 WPBeginner 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 | |
Gravatar Settings | |
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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment