How To Add Gravatar To WordPress Default Gravatar List In WordPress Blog

Posted by


WordPress allows to choose default Gravatar to be displayed on comments when the commentator do not use Gravatars. If you want to add your own avatars to the list then you need to use this hack. For that add this code in functions.php file of your theme:

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’ );

That’s it!


Shane G.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.