Display Gravatar From Email Address
In a previous article you learnt how you can display the the author avatar in WordPress. But if you aren't using WordPress then you will need to use a Gravatar.
A Gravatar is your image that follows you from to different sites and will appear as your image next to your name. So if you make a comment on a blog they will be able to use your Gravatar to display your personalised image. Gravatars helps people become familiar with your image.
Your Gravatar is linked to your email address so if you use the same email addresses on different blogs you will have a different Gravatar.
Display Your Gravatar On Page
To display your Gravatar on the page use the following snippet.
<?php $email = "email@example.com" $gravatar_link = 'http://www.gravatar.com/avatar/' . md5($email) . '?s=128'; echo '<img src="' . $gravatar_link . '" />'; ?>
Display WordPress Author Gravatar
Instead of using the WordPress built in avatar you might want to use your Gravatar on all your posts. To do this you can modify the above snippet.
Go to the single.php page and enter the following where you want to display your gravatar.
<?php $gravatar_link = 'http://www.gravatar.com/avatar/' . md5(get_the_author_email()) . '?s=128'; echo '<img src="' . $gravatar_link . '" />'; ?>
Fastest WordPress Hosting With WPEngine
Stunning speed, powerful security, and best-in-class customer service. At WP Engine.
Join the weekly newsletter
Sign up for our newsletter. You'll be updated on new tutorials as they come available.
Subscribe today and get a 50% discount code to Paulund