How to Change Default WordPress Avatar

LinkedIn
Hacker News

Gravatar is a globally recognized avatar service, being used in most of the WordPress blog today. If you are using gravatar service you just need to register and map your personalized image avatar to your email id once. Gravatar identifies your post and automatically, your avatar will appear on blog (an example below).

Author bio with Gravatar

Gravatar is built in to WordPress and it is used in author bio section. If an user email address is not registered with Gravatar, WordPress allows you to pick some of the boring default images to show as default avatar. Sometimes, “Mystery Person” looks quite boring on a fancy looking website.

-Advertisement-

In this tutorial we will take a drive into how to customize the avatar and add a default image of your choice.

Step-1 Upload New Gravatar Image

Upload the image that you want to show as your avatar to themes image folder. The theme folder can be found in the following path. Here in this example my file name is default-avatar.png and uploaded to the following location.

wp-content/themes/twentyeleven/images/default-avatar.png

Step-2 Adding WordPress Hook

Once you have uploaded your image in the above step, you need to write the below code that works as WordPress hook to add a new default avatar image. Paste the below code inside functions.php file which is located in your themes folder.

/** Add a new default avatar **/
add_filter( 'avatar_defaults', 'add_gravatar' );

function add_gravatar ($avatar_defaults) {
       $myavatar = get_bloginfo('template_directory') . '/images/default-avatar.png';
       $avatar_defaults[$myavatar] = "MY Gravatar";
       return $avatar_defaults;
}

Step-3 Change Default Avatar Settings

Now you are almost done. Just visit Settings -> Discussions -> Default Avatar section in your WordPress admin dashboard, and you will find your newly added avatar image listed as shown in the image below.

Change Gravatar Image WordPress

Thats all. Now you will see your newly created avatar in author bio and other section as per your theme layout.

Related Articles

Join The Discussion

Please note: We reserve the right to delete comments that contains snarky remarks, offensive or off-topic. To know more read our comments policy.