WordPress allows you to choose a default gravatar to be displayed on your comments when the commentator don’t use Gravatars. But what if you wan to add more avatars to the list? That’s easy: simply apply this simple method.
WordPress allows you to choose a default gravatar to be displayed on your comments when the commentator don’t use Gravatars. But what if you wan to add more avatars to the list? That’s easy: simply apply this simple method.
Simply paste this code on your functions.php file. Don't forget to change paths to the images in the code.
if ( !function_exists('fb_addgravatar') ) {
function fb_addgravatar( $avatar_defaults ) {
$myavatar = get_bloginfo('template_directory').'/images/avatar.gif';
//default avatar
$avatar_defaults[$myavatar] = 'people';
$myavatar2 = get_bloginfo('template_directory').'/images/myavatar.png';
//Avatar for user "admin"
$avatar_defaults[$myavatar2] = 'admin';
return $avatar_defaults;
}
add_filter( 'avatar_defaults', 'fb_addgravatar' );
}
Thanks to WpEngineer for this great hack!
Leave a Comment