Now that Gravatar support is part of the WordPress core adding them into your WordPress theme is easy. Adding them to your comments has been documented. How about adding them to your post titles to highlight the comment author? Within the loop? That’s fairly easy too. Here’s the code:
<?php echo get_avatar( get_the_author_email(), '80' ); ?>
Pretty simple, huh? get_the_author_email outputs the post author’s email and the “80” is the size of the avatar image in pixels (you can change that). How this will look depends on how you use it; where you put it in the theme (it has to be in the loop!) and how you style it.
Want an example? I had to figure this out for an upcoming project so…
Look at that frighteningly intense young man there in black and white. Good grief, it’s me! The author of the post! The code, it works! It works!
Ahem. Excuse me. I get a little excited about these things. Good luck using it in your own theme!
By the way, did you know WordPress has built in email protection from spam bots (read Disguising Your Email)? I didn’t. Neat.
162 responses
That’s pretty cool Ian. I enjoying reading your WordPress tips and your new Amazon bookstore looks cool. I gotta find some time to read your creative thinking recommendations.
[…] up Gravatars to display with each individual post? Over at ThemeShaper, Ian Stewart recently shared an easy way to do this. You just need the following […]
Thanks, Jason. That reminds me: I forgot Thomas Kuhn.
Cool! I love the idea. I’ve seen some sites with the author’s avatar right after the post but isn’t this gravatar thing more applicable in a multi-user blog?
Totally. I wouldn’t recommend using it unless you’re on a multi-user blog.
might have to use this then as it would be handy especially for my website.
Thanks
[…] mostra come aggiungere i gravatar per mostrare il volto dell’autore di un post, ecome costruire una navigazione tra le pagine di WordPress con Wp-PageNavi, come mostra la figura […]
[…] shows how to Add Gravatars For The Post Author in WordPress, and How To Build WP-PageNavi Into Your WordPress […]
[…] wordpress known as SimpleSkin. Made from scratch using Small Potato’s guidelines. Included gravatar support from Themeshaper, and design influences from FreelanceSwitch and again Themeshaper. Free to […]
You’re totally talking about my latest theme. I implemented this technique in WPFreemium but instead of using the author’s email, I used their ID e.g. “the_author_ID();”.
It took me hours trying to find out how this worked at first since I couldn’t find any documentation in the codex I had to dig into the core files.
The theme you’ve come up with is a great example what I’ve outlined, Ptah. Very cool.
And it’s totally frustrating when you know, in theory, you can do something and quickly realize you’re going to have to figure out how to do it yourself. Except of course when you figure it out. Then, well, that’s awesome. 🙂
hai ian, can you point which specific place to put the code, because i have not found where the loop is? in comment.php, single.php or where?
That would be The Loop.
[…] ThemeShaper dobta múltkor azt a bejegyzést, ami azt írja le, hogyan lehet ezt a kis identifikáló ikont […]
[…] to display with each individual post? Over at ThemeShaper, Ian Stewart recently shared an easy way to do this. You just need the following […]
[…] Add Gravatar for post author […]
[…] Add Gravatar for post author […]
[…] 2、显示作者Gravatar头像 […]
[…] 2、显示作者Gravatar头像 […]
[…] 2、显示作者Gravatar头像 […]
[…] 2、显示作者Gravatar头像 […]
[…] 2、显示作者Gravatar头像 […]
[…] 2、显示作者Gravatar头像 […]
[…] 2.显示作者 Gravatar 头像 […]
[…] 2、显示作者Gravatar头像 […]
I still don’t understand exactly where i’m supposed to place the code. Where should i put it if i want it to look like in the picture? could you please show me?
Where you put the code, Thomas, depends on the theme you’re using (remembering it has to be in The Loop) and how you style it, or position it, using CSS. Give it a try. It’s kinda fun.
Ok thanks for the quick reply
I really don’t know much CSS, but i just discovered that the theme i use, apparently has a single php file for most of the loop stuff… Im going to try to mess around with that, ive managed to do a lot by trial and error before…
By the way do you have any idea how i can find the part of the code that shapes the post headline area? like specific terms to search for or something. I also need to change the color of the headlines themselves, but thats probaly somewhere else…
[…] 2、显示作者Gravatar头像 […]
[…] Add Gravatar for post author […]
[…] Agregar Gravatar del autor de cada post, ver cómo. […]
[…] 2、显示作者Gravatar头像 […]
[…] Agregar Gravatar del autor de cada post, ver cómo. […]
[…] Añade gravatar del autor a los posts […]
[…] Добавляем к постам потрет/аватар автора […]
[…] Agregar Gravatar del autor de cada post, ver cómo. […]
[…] |enlace| […]
[…] 2. Añadir un pequeño avatar del autor del mensaje. […]
[…] Add Gravatar for post author […]
[…] Añade gravatar del autor a los posts […]
[…] Exibir o avatar dos autores dos posts […]
[…] Agregar Gravatar del autor de cada post, ver cómo. […]
Hey, how u did put the align=”right” only to the gravatar image?
can u put me the code u did use to get that exact style?
[…] 2、显示作者Gravatar头像 […]
[…] Agregar Gravatar del autor de cada post, ver cómo. […]
[…] Agregar Gravatar del autor de cada post, ver cómo. […]
Koooooool… Preety simple. I will try the same. Thx.
[…] 2、显示作者Gravatar头像 […]
[…] 2、显示作者Gravatar头像 […]
[…] 2、显示作者Gravatar头像 […]