Add a Custom Avatar
January 7th 2011Adding a custom Gravatar for your WordPress website is really quite simple.
Create your custom Gravatar and drop it into the image folder of your template. If you choose to put it elsewhere, simply change the 4th line of code to reflect the new location (also pay attention to the file type and adjust for png/gif/etc.).
Open up your functions.php file within your theme folder (if this doesn't exist, create it). Paste this code directly before the closing ?>.
// Add a default avatar to Settings > Discussion
if ( !function_exists('fb_addgravatar') ) {
function fb_addgravatar( $avatar_defaults ) {
$myavatar = get_bloginfo('template_directory') . '/images/avatar.jpg';
$avatar_defaults[$myavatar] = 'My Avatar';
return $avatar_defaults;
}
add_filter( 'avatar_defaults', 'fb_addgravatar' );
}
This will add a new option of My Avatar to the Gravatar choices on the Discussion settings page.