If you’ve ever wanted to change the default avatar in WordPress, all you need is a quick filter in functions.php that inserts and names your new avatar. Once you add the markup below, you’ll see your new avatar type listed in wp-admin > Settings > Discussion along with the choices like Identicons and MonsterID. The code:
<?php
add_filter( 'avatar_defaults', 'newavatar' );
function newavatar ($avatar_defaults) {
$myavatar = get_bloginfo('template_directory') . '/images/avatar.png';
$avatar_defaults[$myavatar] = "Pigs";
return $avatar_defaults; }
This is a pretty simple one. Our function newavatar() is hooked to the avatar_defaults, and we simply add our new avatar choice, which includes a path to the image URL along with a title (pigs!). At the end, we return the defaults, which has been impregnated with our new custom avatar, and no one is ever the wiser!
Hi Clark. I have seen and used this before, but now I am experiencing that now matter what URL you send, WP puts a http://gravatar.com in front of it, which breaks the image on the Discussion Settings page (and I presume everywhere else). Have you seen this? Do you have any idea how to get around this?
Hi Kathy,
I have your same problem, have you found the solution? Really curious about that!
I believe this code goes to your functions.php in your theme. And when you select an default avatar, you will see a new option to select.