Add Custom Default Gravatar Image

WordPress uses Gravatar to display user profile photos in WordPress. If a user does not have a gravatar, then WordPress uses a default image which is called ‘Mystery Person’.

This default gravatar image will appear many times in your WordPress comments area simply because a lot of users do not have a gravatar image associated with their email address.

You can easily replace this default gravatar with your own custom default gravatar image.

First you will need to upload the image you want to use as your default gravatar image to your WordPress media library.

Next, you need to copy the image file URL.

Now you need to add the following code to your theme’s functions.php file or a site-specific plugin.

add_filter( 'avatar_defaults', 'wpb_new_gravatar' );
function wpb_new_gravatar ($avatar_defaults) {
$myavatar = '';
$avatar_defaults[$myavatar] = "Default Gravatar";
return $avatar_defaults;

Don’t forget to replace $myavatar value with the URL of the custom gravatar image you uploaded earlier.

You can now visit Settings » Discussion page, and you will notice your custom default avatar added to default avatar choices.

admin Isaac

Author: admin