Simple Steps To Change Default Gravatar In WordPress

WordPress is a beautiful blogging CMS and can be easily personalized, but at many case WordPress users are forced to use the default gravatars or avatar.  So in this post I will teach you how to change the default gravatar for your WordPress blogs. Basically WordPress comes with some default gravatars which can be see through Settings> Discussion. Hence this tutorial will teach you to add another default gravatar, which is going to be your custom made gravatar for your WordPress blog.  Lets head on to the tutorial.

Change default gravatar in WordPress

Step 1: Most of the WordPress theme has functions.php template file. So check for the file using Appearance > Editor. If you don’t find functions.php create a new PHP file with the name functions and paste the code within the file.

add_filter( 'avatar_defaults', 'newgravatar' );

function newgravatar ($avatar_defaults) {
    $myavatar = get_bloginfo('template_directory') . '/images/gravatar.jpg';
    $avatar_defaults[$myavatar] = "YourBlogName";
    return $avatar_defaults;

Once you add the code in functions.php, you need to change default path with your own, then type your blog name instead of YourBlogName and update the file. That’s it. (Make sure that you add the image file within the template directory and don’t use any external server to link up the image)

Step 2: Navigate to Settings > Discussion and at the bottom, you can see your new avatar being added to the default gravatar list. So just click on it and save the changes.

Wordpress dashboard discussion

Credits (Thanks to Zach for the original code)

May 21, 2010. This entry was posted in Tutorials, WordPress and tagged . Bookmark the permalink.

We Recommend HostGator Hosting

Bloggermint strongly recommends Hostgator Hosting for all of your web hosting needs. Sign up today for WordPress Hosting at just $4.95/month.

Use coupon code "bloggermint" to get 25% discount on any hosting packages. Get an account with Hostgator now!

13 Responses so far!

  1. Pingback: Tweets that mention Simple Steps To Change Default Gravatar In Wordpress | Bloggermint --

  2. great post, it helps to look the comment more attractive that usual.
    .-= freshtutorialdotcom´s last blog ..Beginner guide to wordpress =-.

  3. thanks! I used this to replace my existing code which was 3 times as long.

  4. Thanks for this! It was exactly what I was looking for.

  5. hey! in new user here and i just wanne say hello

  6. Thanks for this hack, it worked. However – it seems wordpress still redirects to I’m trying to make my site faster. And minimizing redirects is on the top of my to-fix list. How can i completely remove gravatar calls?

  7. This is another best method to change the default gravatar. Other one is get_avatar(email,size, ‘location of your new avatar’) . I think this is great method if you are selling a custom wordpress setup to your customer.

  8. one off beat question, How did you implemented this edit comment method. If possible please write a tutorial on this.

  9. Why is this not working for me? I am using a Child Theme, but I that should be fine since I changed ‘template_directory’ to ‘stylesheet_directory’.

    Here is my code:

    function add_custom_gravatar ($avatar) {
    $custom_avatar = get_bloginfo('stylesheet_directory') . '/images/default-gravatar.jpg';
    $avatar[$custom_avatar] = "IFE Default Gravatar";
    return $avatar;
    add_filter( 'avatar_defaults', 'add_custom_gravatar' );

  10. hi,

    wp 3.5 not work

Leave a Reply

Your email address will not be published. Required fields are marked *