Adding a custom default gravatar to your site

Looking to get rid of that "Mystery Man"? Don't like the Identicon or Wavatar? Learn how to add your own custom @Gravatar..

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!

Austin
Austin

πŸ’πŸ½β€β™‚οΈ Husband to Jeana.
⚾️ Dodgers & Brewers.
πŸ’» PHP Engineer.
πŸŒπŸΌβ€β™‚οΈGolfer; ~14 HDC.
🌱 Hydroponic Gardner.
🍿 Plex nerd.
πŸš™ '15 WRX, '22 Model 3 LR, & '66 Corvette C2.

Follow me on Twitter @TheFrosty & Instagram @TheFrosty.

Articles: 292