How to Change the Default Gravatar in WordPress

Share:
Share

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 ! ;)

If you really found it useful, don’t forget to share it with your friends. Also, if you have problems following the tutorial.. leave a comment and We’ll be there to help you out !

Share:
Share

Tags: , ,

9 Responses to “How to Change the Default Gravatar in WordPress”

  1. Sheharyar Naseer 10. Sep, 2009 at 11:48 pm #

    Thnx alot! was looking for this

    [Reply]

  2. Enk. 10. Sep, 2009 at 11:50 pm #

    You’re Welcome ! :)

    Now you can also contact for Custom WordPress Tutorials or Help using the Contact Page ! :)

    [Reply]

  3. Kristina 26. Oct, 2009 at 11:56 pm #

    This worked great, finally code that worked!!
    Kristina´s last blog ..No Man Is An Island My ComLuv Profile

    [Reply]

    Enk. Reply:

    Glad to hear that Kristina. Keep coming back for more tutorials. :)

    [Reply]

    Kristina Reply:

    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 My ComLuv Profile

    [Reply]

    Kristina Reply:

    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 My ComLuv Profile

    [Reply]

    Enk. Reply:

    You’re always more than Welcome here Kristina ! :)

Trackbacks/Pingbacks

  1. How to Change the Default Gravatar in Wordpress ? - Wordpress Tutorials - 10. Sep, 2009

    [...] Follow this tutorial I wrote here on my new Blog ! [...]

  2. uberVU - social comments - 07. Dec, 2009

    Social comments and analytics for this post…

    This post was mentioned on Twitter by enked: How to Change the Default Gravatar in WordPress http://digg.com/u1CJuo (via: @WPPanda)…

Leave a Reply

CommentLuv Enabled