Gravatar is one of the best features of the WordPress. It is nothing but the image associated to your email id. Whenever you use this email address for placing comments or create profiles in WP blog, the image associated to your email is displayed.
You can read more about Gravatar on WP because this tutorial is not about ‘what is gravater?’ So in this tutorial I am going to show you how to change the default “Mystery Man Gravatar” to your very own “Guest Gravatar”.
You can use gravatar in wordpress with the gravatar wordpress plugin or it can be manually added in index.php, comments.php and comments-popup.php
Many times the gravatar comes with the WordPress Theme, so in this case it is located in the functions.php file. This file is responsible for additional options of the theme which appears in the WordPress Dashboard. So let’s add the new gravatar.
Open functions.php file. Add the following code at the end of the file just before and save it.
1 2 3 4 5 6 7 8 9 |
/* Powerusers Gravatar /* ----------------------------------------------*/ add_filter( 'avatar_defaults', 'newgravatar' ); function newgravatar ($avatar_defaults) { $myavatar = get_bloginfo('template_directory') . '/images/p-gravatar.jpg'; $avatar_defaults[$myavatar] = "Powerusers Gravatar"; return $avatar_defaults; } |
Explanation:
First line is adding a “newgravatar” to the default avatars (avatar_defaults) available in the WordPress.
1 |
add_filter( 'avatar_defaults', 'newgravatar' ); |
Next the newgravatar function is providing the location of the image which is in the images folder of the WP installation directory and assigning a name “Powerusers Gravatar” to it.
1 2 3 |
function newgravatar ($avatar_defaults) { $myavatar = get_bloginfo('template_directory') . '/images/p-gravatar.jpg'; $avatar_defaults[$myavatar] = "Powerusers Gravatar"; |
And finally the output is sent back to default avatars (avatar_default) which displays the gravatar in the default gravatar list in the dashboard.
1 |
return $avatar_defaults; |
Now go to your Dashboard->Setting->Discussion. Scroll down the page and select your new default gravatar. And you are done.

You can customize the size and look of the Gravatar for the comments section.
For changing the size, open functions.php again and look for the following code and change the size in $size=” ” field.
1 |
get_avatar( $comment, $size='50' ); |
You can customize the look by editing the style properties for gravatar class in the style.css file.
So now on there will be no Mystery men in your blog.
What do you think about the Mystery Man? Do you want to keep the Default Gravatar or want your own? Let us know in the Comment!
Akshay
Nice blog. very informative, just change my default gravatar.
Nikhil
Thanks Akshay,
I am glad that this tutorial helped you a little bit.
How to Change Default Gravatar in Wordpress | Web Design Updates
[…] How to Change Default Gravatar in WordPress […]
Petty
Interesting article, thanks for posting
Nikhil
you are welcome Petty!
CSS Brigit | How to Change Default Gravatar in Wordpress
How to Change Default Gravatar in WordPress…
Gravatar is one of the best features of the WordPress. In this tutorial I am going to show you how to change the default “Mystery Man Gravatar” to your very own “Guest Gravatar”….
How to Change Default Gravatar in Wordpress | Design Newz
[…] How to Change Default Gravatar in WordPress […]
ezhil
simple and easy way to bring gravatar in your comments http://flexlearner.wordpress.com/2009/12/17/how-to-add-gravatar-to-your-wordpress-comments/ it just took me 5 minutes to do that.
Ralph Contreras
Awesome! Thanks to the tutorial.Took me about 5 minutes to change the default gravatar avatar. It took me longer to decide what I should change it to. Thanks a bunch! – SHAZAM!
Nikhil
Ha Ha!
Very Nice!
I am glad that the tutorial helped you.
Thanks
shahab
Hi
I did all things and it added a new avatar radio button but i don't know where i should upload the picture?
'/images/p-gravatar.jpg' where "images" folder?
Please tell me,
Thanks,
shahab
Please help!
Where should i upload the avatar?
what folder?
Nikhil
Hello Shahab,
upload your image to
wp-content/themes/your theme name/images/
shahab
Thanks,
Yesterday i finally found it 🙂
And thanks from your reply. and your code.
many thanks.
😀
Wordpress, links que me ajudaram na criação de Widgets e Plugins. » Wellington Rocha
[…] http://nikhilmisal.com/how-to-change-default-gravatar-in-wordpress/ […]
Magnolia Clare
Thank you very much for this tuturial. It helped me to change my functions.php file and now I have a cute cupcake as my default gravatar instead of the Mystery Man.
Thanks again,
MC
web design
good job..
Thanks
tomy
Super, thanks very much!
Klaus
Great work! Worked like a charm in WP 3.03! Thanks a bunch.
Latest Gravatar news – How to Change Default Gravatar in Wordpress | Powerusers
[…] How to Change Default Gravatar in WordPress | Powerusers […]
nik
Thanks bro!
Preston
Bravo good sir, bravo! I’ve been trying to figure this out for weeks now and I’ve read countless articles and have tried so many plugins with no success. I copied your code, added it to my functions.php file, and changed the image name to my image and bam worked the first time no problems. I am very thankful. I really appreciate people like you that help others with good legit information. Great job man. I will be adding you on twitter and following you future posts. I’m a fan for life now!
Jim
Wow, that is awesome!
daily news
Great tips! it’s work on my site, thank you.
Nikhil
thanks mate…
🙂
sreekanth
is it depends on theme
bcoz i tried doing but nothing works out
Ferman Aziz
thanks just implemented on my blog
Stole
Now matter what URL you send, WP puts a http://gravatar.com in front of it, which breaks the image on the Discussion Settings page. How can I fix this?