Requirements
- Must be using a self-hosted WordPress platform.
- Must be able to edit your functions.php theme file (or create a new one if one does not already exist).
What We’ll Be Creating
As you may know, on WordPress, in the “Discussion” settings, you have the option of setting a default avatar. This avatar will appear whenever someone who doesn’t have their own avatar (usually from Gravatar.com) posts a comment on your blog. The default avatars available are… not that attractive. Here are some of the options:
If you really want to go all out personalizing your blog, you may want to set your own custom default avatar! Perhaps to your site logo or to something more bookish. Well let’s get started!
Step 1: Create & Upload Your Custom Avatar
The first step is to create your avatar using Photoshop or any other image editing program. Be sure to save the avatar in a GIF, PNG, or JPG format. Then, you need to upload the image to your site. You can save it wherever you want — in the theme file or just upload it regularly using WordPress’s built in media uploader.
Once you’ve done that, you need to locate and open your functions.php file. This is located in your theme directory. Make sure your functions.php file is enclosed in php tags like so:
<?php //Code here ?>
If it’s not, you’ll have to add those in yourself.
Then, paste the following code into the body of your functions.php file (inside the php tags):
//Custom Gravatar add_filter( 'avatar_defaults', 'newgravatar' ); function newgravatar ($avatar_defaults) { $myavatar = 'http://www.custom-avatar-url.png'; $avatar_defaults[$myavatar] = "Your Avatar Name"; return $avatar_defaults; }
Obviously you’ll have to change the URL I have in there to the URL of your own custom avatar.
Then save your functions.php file, navigate back to the WordPress » Settings » Discussion page, and if you followed the instructions correctly, your new image should be listed as an option for your default avatar! Simply select your new avatar, save your settings, and you’re done!
Yay, it worked! Thanks so much for this post– now my blog is just a little bit cooler. 😀
I’m so glad it worked for you!! 🙂
does it need to be a certain size, or will it automatically resize to avatar size?
It should resize, but I still recommend that you manually shrink it down, at least close to what would be displayed on your blog. 🙂
This is so dam cool! Thanks 😀
Ooo I like!!
Oh neat, thanks for pointing me to this post Ashley. So in essence, when we use this it would only show the custom avatar for the folks who don’t already have a Gravatar setup right?
p.s. used the CommentLove plugin on my site, and it works great! Soon enough I’ll actually follow the tut and build upon it to maybe include some other settings, or definitely at-least style it to match my current site more. Thanks for sharing it 🙂
Yes that’s right. 🙂 This is the default if they don’t already have their own custom one.
I’m so glad you’re liking the Comment Love plugin! Woohoo!