March 25, 2009
How to Add the Author’s Gravatar in Posts
There are tons of sites out there that will use avatars along with usernames when displaying posts. On a WordPress blog, the easiest way to do that is by using gravatars. This is a site that is run by Automattic, and you can upload an avatar, that is then attached to your email address. This little hack will show your avatar to people on your site, but only if you are using the same email for your gravatar account and WordPress acount.
Just place this code in your index.php, and single.php, where you want the avatar to be displayed:
<?php $author_email = get_the_author_email(); echo get_avatar($author_email, '96'); ?>
And it’s as easy as that!
Previous Post and Next Post