Are you Bored of your WordPress Default Gravatars? Or just want to have your own cool default Gravatar ? Well, atleast that is what I wanted and that me write this simple tutorial for you. Follow these simple steps and you’ll end-up having a cool new Gravatar for your Blog !
Each WordPress Theme has a “function.php” file which is responsible for the theme functions like Sidebar Widgets, etc. Like the Kubrick Theme (default wordpress theme), the function.php is responsible to change colors of the header. Just like that every theme has one to do stuff like that.. if you don’t have it already. Create one now! It’s as simple as Open Notepad. Save file as functions.php
. You don’t have to worry about the pre-written code in the file if you have one. This code is independed from rest of the code.
Just add these lines to your Functions.php:
add_filter( 'avatar_defaults', 'YOURTHEMENAME_addgravatar' );
function YOURTHEMENAME_addgravatar( $avatar_defaults ) {
$myavatar = get_bloginfo('template_directory') . '/images/wppanda-gravatar.png';
$avatar_defaults[$myavatar] = 'Wordpress Panda';
return $avatar_defaults;}
It’s actually a relatively simple function. You’ll only need to change the image location and avatar title to your own needs. For those interested in the full process, here’s a more specific breakdown of what’s going on:
- The add_filter function says that we’ll be editing the avatar_defaults array using our custom function “newgravatar”
- The newgravatar function is responsible for providing the location and title of our additional gravatar option
- The first line in the function points to the new gravatar in the images folder of the template directory
- The second line designates the name that will be displayed next to the image dashboard options.
- The third line sends back the results to the avatar_defaults array to be included in the theme
Go Go Mystery Man !
It’s easy to change the default gravatar of your Blog with a couple of lines and kick the Mystery Man off your WordPress. If you want to have a couple of choices at once, just copy and paste those lines again and rename the “$myavatar” variable each time. Its time to say buhbye to Mystery Man, it was nice blogging with him !




Thnx alot! was looking for this
[Reply]
You’re Welcome !
Now you can also contact for Custom WordPress Tutorials or Help using the Contact Page !
[Reply]
This worked great, finally code that worked!!
Kristina´s last blog ..No Man Is An Island
[Reply]
Enk. Reply:
October 27th, 2009 at 9:37 am
Glad to hear that Kristina. Keep coming back for more tutorials.
[Reply]
Kristina Reply:
October 27th, 2009 at 8:14 pm
Hmm, unfortunately now it is not showing up in IE. Not sure what happened…shows up fine in Firefox, but IE shows up as a red X image, because from right clicking it appears it is searching for an image at: http://www.gravatar.com/avatar/12cf48b1699eae8d9d45f557404a153a?s=48&d=http%3A%2F%2Fkristinamedh.us%2Fwp-content%2Fthemes%2Fcarrington-blog%2Fimg%2Fgravataricon.gif%3Fs%3D48&r=G
obviously there is some kind of parsing(?) problem here? with %2F not being translated to / and the like?
Kristina´s last blog ..No Man Is An Island
[Reply]
Kristina Reply:
October 27th, 2009 at 8:16 pm
Nevermind. It was when i added my site to “Trusted Sites” in IE preferences that it got all screwed up. Fixed now.
Thanks for a great plugin!!
Kristina´s last blog ..No Man Is An Island
[Reply]
Enk. Reply:
October 27th, 2009 at 8:56 pm
You’re always more than Welcome here Kristina !