What is a default Gravatar?
Gravatar stands for Globally Recognized Avatar. It is globally recognized because millions of websites use them. It’s the most popular application and platforms like WordPress have built-in support for Gravatar. When a user leaves a comment (with their email address) on a site that supports Gravatar, it pulls their Globally Recognized Avatar from Gravatar servers. Then that picture is displayed next to the comment. This allows each commenter to have their identity throughout the internet.
But you wouldn’t want just a simple ghost showing up in your comments right?
First, you’ll need to create a graphic that will be intended as the default Gravatar. On this site we use
I would recommend using the size 96×96 when creating this (you should also name it avatar.png).
Once you have this saved somewhere on your computer you’ll need to upload (FTP) it to your theme in the image folder.
Now head over the to the functions.php
file and add this code below.
//* Create a custom Gravatar
add_filter( 'avatar_defaults', 'riot_custom_gravatar' );
function riot_custom_gravatar ($avatar) {
$custom_avatar = get_stylesheet_directory_uri() . '/images/avatar.png';
$avatar[$custom_avatar] = "Custom Gravatar";
return $avatar;
}
Don’t forget to save your work.
From your Dashboard, you’ll need to click on Settings > Discussion
Select your Custom Avatar and hit save.
Now everyone who comments that doesn’t have a Gravatar attached to their email address will now show up as the photo you uploaded.
Share Your Thoughts