Avatars are gaining on popularity since Gravatars support was included in the WordPress version 2.5. If you are no longer happy with the default WordPress avatar named Mystery Man, you can now change it with your custom picture.

Follow these steps:
1. Login to your FTP server where WordPress is located.
2. Navigate to your current theme folder wp-content/themes/mywordpresstheme.
3. Open functions.php with your favorite text editor or manually create a file if it doesn’t exist yet.
4. Scroll down to the latest line, just before ?> and insert the following code:

/* WpFreaks.com - Start of Default Avatar Modification */
if ( !function_exists('fb_addgravatar') ) {
function fb_addgravatar( $avatar_defaults ) {
$myavatar = get_bloginfo('template_directory') . '/images/useravatar.png';
$avatar_defaults[$myavatar] = 'Users';
$myavatar2 = get_bloginfo('template_directory') . '/images/myavatar.png';
$avatar_defaults[$myavatar2] = 'My Avatar';
return $avatar_defaults; }
add_filter( 'avatar_defaults', 'fb_addgravatar' ); }
/* WpFreaks.com - End of Default Avatar Modification */

6. Create an avatar for users of your choice and name it useravatar.png, and optionally your own avatar titled myavatar.png.
7. Upload them to wp-content/themes/mywordpresstheme/images directory.
8. Login to your WP admin area, under General Settings > Discussion to finally select your new default WordPress avatar.
9. Save changes.

Note: Recommended size for the avatar is 60x60px.


  1. Thanks. This what I needed for my fashion WP site.

  2. Anonymous

    I just made this work for my site. Ty!!

  3. thank you guys..it worked

  4. custom avatars look so much better on my wp blog!!

  5. Nice one! and a love wpfreaks! keep up the good work

  6. Err… why is #myavatar2 for? i mean, why two images and variables when we need only 1? Am i missing something here? :/

    • One is default avatar of your blog and one is your own (admin) avatar. I hope this is now clear.

  7. This is great! I’ve been searching for hours. What I am looking for is a way to randomly choose the new avatar. I’m getting better with functions and PHP but I’m not sure of the code which is need.

    I’m guessing there is a snippet that can be added to your code to tell it to choose from a folder of images?

    • Did you manage to work this out? If not I can probably help you with this.

  8. hay i am using this code but it all the time showing me broken image…

    and by using fire bug..it gives error…..what should i do?

  9. Tony Assante

    is possible change all images of de fault avatar

    Like this every person who comment on my site is ever same foto.

    I want a different foto for person dont registered on gravatar or wordpress…

    Is possible?

Related Posts