Adding a custom default gravatar to your site

Notice on some site’s how they’ve got a different gravatar than the usual “mystery man”? Ever wonder how that is done? Well it’s really simple.

Were going to add a few lines of code to your functions.php file:

function wag_gravatar ( $avatar_defaults ) {
	$myavatar = 'full-path-to-image/wag-gravatar.png';
	$avatar_defaults[$myavatar] = 'WPWag';

	return $avatar_defaults;

That’s the whole function! I told you it was easy.

Gravatar Options

New Gravatar option “WPWag”

Just be sure to add the correct filter.

add_filter( 'avatar_defaults', 'wag_gravatar' );

Let’s see your default gravatar’s!