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 obsessed.
💻 WordPress Engineer.
🏌🏼‍♂️Golfer.
🌱 Hydroponic Gardner.
🍿 Plex nerd.
🚙 '15 WRX & '66 Corvette C2.
🐶 Missing my love Keiki; RIP 😢.

Follow me on Twitter @TheFrosty & Instagram @TheFrosty.

Articles: 288

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: