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!

Default image
Austin
πŸ’πŸ½β€β™‚οΈ Husband to Jeana. ⚾️ Dodgers obsessed. πŸ† World Series Champs. πŸ’» Lead Software Engineer @ Beachbody. πŸŒπŸΌβ€β™‚οΈScratch golfer. 🌱 Hydroponic Gardner. 🍿 Plex nerd. πŸš™ '15 WRX & '66 Corvette C2. 🐢 Missing my love Keiki; RIP 😒. Follow me on Twitter @TheFrosty & Instagram @TheFrosty.
Articles: 285

Leave a Reply

%d bloggers like this: