Mika MAtikainen
Apr 15, 2020 · 4 min read
Display a custom gravatar in WordPress
Make sure you upload your custom gravatar image to the indicated directory and edit “My custom gravatar” to something that meets your needs.
[code lang=”php”]
function display_gravatar($avatar_defaults) {
$myavatar = get_bloginfo(‘template_directory’) . ‘/images/custom-gravatar.png’;
$avatar_defaults[$myavatar] = ‘My custom gravatar’;
return $avatar_defaults;
}
add_filter(‘avatar_defaults’, ‘display_gravatar’);
[/code]