• Blog

    Latest from our Blog

  • Tools

    Our Favourite WP Tools

  • Hosting

    Recommended Web Hosts

  • Coupons

    Get great money off deals

  • Themes

    WordPress Theme Directory

  • Plugins

    WordPress Plugins Directory

  • Promote

    Your WordPress Product

Gravatar is a service from Automattic which stands for “Globally Recognized Avatar”, you can signup on their site and upload an avatar for yourself and then when you use the same email when commenting on WordPress blogs it will show up. When a user comments and they haven’t signed up for their own Gravatar, WordPress has a number of default ones built-in that it will display instead. You can choose which is shown, in your WordPress admin, go to “Settings” > “Discussion” and scroll down and you will see the options :

Most blogs just use the default “Mystery Man” – in this post I will show you some code you use in your theme so you can add your own custom option.

Open your theme’s functions.php file and paste the following code :

    add_filter( 'avatar_defaults', 'newgravatar' );

    function newgravatar ($avatar_defaults) {
    $myavatar = get_bloginfo('template_directory') . '/images/GRAVATARHERE.png';
    $avatar_defaults[$myavatar] = "NAMEHERE";
    return $avatar_defaults;
    }

There are two options you can change, the first is the path and file name of your avatar image, this points to the images folder in your theme directory and the image name is “GRAVATARHERE.png” – change to what you like.

/images/GRAVATARHERE.png

The other piece of code to change is “NAMEHERE” – this is what the gravatar is called in the WordPress discussion options screen. Change it to what you like.

NAMEHERE

And that’s it, you can now visit your discussion settings in the WordPress admin and you will see your new option, choose it and hit Save and it will now appear in your theme.

Some Gravatars for you to Download

I have put together an avatar pack for you to use in your themes for free, the icons were found on FindIcons.com.

The Zip file contains 24 icons and a .PSD file if you wish to modify them or the background color.

Download Gravatars (1.21MB) ยป

License

These Avatars are released under the GPL 2 License which means they are free to download and use for yourself or clients and modify it anyway you see fit.


Author:

Oliver Dale is the founder of Kooc Media, a small internet company based in the UK. Kooc Media runs several high-profile websites including WPLift, ThemeFurnace and DesignersTalk.

Leave Yours +

4 Comments

  1. bookmarked it… will surely use it for my personal blog…

  2. nice info..thanks for sharing….

  3. Anonymous

    This is very simple, but thanks for the code

  4. Anonymous

    This is very simple, but thanks for the code

  • Comments are Closed

Search

Our Sponsors