Usually Gravatar integrates with WordPress. This makes even easier to add an image in comments section while commenting on WordPress blog using the email addresses that are familiar with Gravatar.com. This means to add an avatar in comments on WP blogs you don’t need to have an account for each, just create an account on Gravatar and get started with an awesome avatar in comments only for WP blogs. Today, we are going to show you how to add custom Gravatar image in comments?

How to Add custom gravatar in WordPress

If you someone is familiar with Gravatar.com how would it be possible to show a gravatar image for him. Usually when an unknown person comment on WordPress blogs, WP automatically show a gravatar image of Gravatar.com. That blue gravatar image may some people don’t like to have and want to convert that image with their own website brand like softstribe did.

Gravatar image in WordPress

Adding Custom Gravatar in Comments

Follow the steps below to add a custom gravatar image in your WordPress blog.

1. Upload an image with size of 32px x 32px in the root directory wp-content/themes/your-theme/images/gravatar.png.

2. Locate the following code in your theme’s functions.php file.

add_filter( 'avatar_defaults', 'new_avatar' );
function new_avatar($avatar_defaults){
$new_avatar = get_stylesheet_directory_uri() . '/images/gravatar.png';
$avatar_defaults[$new_avatar] = "Softstribe";
return $avatar_defaults;
}

3. After adding the above code in the functions.php double check the image name in the above code on the line 3 and name of your website on line 4.

4. Go to Settings > Discusstion, jump at the bottom of the page and select the custom gravatar like this:

Softstribe custom gravatar image

5. Click the button Save Changes

Congrats