Add New Default WordPress Gravatar

WordPress have the capability to let you choose the default image to replace the Gravatar image in comment section if your commentator has no Gravatar under their email account.

Gravatar comment section

Gravatar comment's section

Change default WordPress gravatar

Option to change default WordPress gravatar

However, your WordPress blog would be more versatile if your WordPress blog have your own designed or logo as the default gravatar. It is really easy to add more gravatar images into the list. Just simply copy and paste below codes into your WordPress blog’s functions.php file.

if ( !function_exists(‘fb_addgravatar’) ) {
function fb_addgravatar( $avatar_defaults ) {
$myavatar = get_bloginfo(‘template_directory’).’/images/avatar.gif‘;
//default avatar
$avatar_defaults[$myavatar] = ‘people’;

$myavatar2 = get_bloginfo(‘template_directory’).’/images/myavatar.png‘;
//Avatar for user “admin”
$avatar_defaults[$myavatar2] = ‘admin’;

return $avatar_defaults;
}

add_filter( ‘avatar_defaults’, ‘fb_addgravatar’ );
}

After you paste above codes in the function.php file, what do you need now is to change the bold red codes with your very own images which you have to upload first into your hosting.

When  you have finished tweaking above codes, you will have 2 Gravatar images in the default gravatar images.

If you enjoy reading this post, how about you share it with others? I will definitely appreciate it.

6 Responses to Add New Default WordPress Gravatar

  1. Very cool. Can we paste this code anywhere in functions.php?

  2. Helmi Asyraf (admin) says:

    Yes but if you want to make this process way faster and easier, I just found a great WordPress plugin – Avatars which will help you to set up the above stuffs.

    Check it out. It would be handy for you.

  3. Thank you. I think I already installed it as well.

  4. ariff says:

    Nice! Was looking for this. It’s kind of disappointing to see other bloggers still dont have their own gravatars.

  5. Kushal Chap says:

    I hope you like mine. Everyone should have one.

  6. Mike says:

    oh wow this is cool. I dont like the grayed out image worpress creates. In the facebook comments tng plugin you can also create a default gravatar for imported comments

Leave a Reply

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