following code into your comment loop will work, but it probably won't look very good as is. <?php if(function_exists('get_avatar')) { echo get_avatar($comment, '50'); } ?> Basically, this code will check if you have get_avatar (native to WordPress 2.5) and then display the commenter's avatar in a 50px square. Use a ruler If you want to make sure your gravatars are a good size, I recommend the MeasureIt Firefox extension. It will help you measure an area on your theme to determine a good size for your Gravatars.
Where to put the code? In the Choice theme, I found that bahamas whatsapp number data 40 was a good size. So where did I put this code exactly? Choose Gravatar Location Anywhere inside the foreach and endforeach (the comment loop) will work. How to style your gravatars Once the Gravatars are displayed in the comment template, you’ll probably want to style them as well. You’ll notice that the Gravatar code displays the “avatar” class on each image. Let’s add a line to the CSS stylesheet to float it to the left and add a small right margin.
img.avatar {float:left; margin-right:5px;} There you have it, beautiful gravatars, perfectly sized and styled. Of course the themes will be different, you can style them however you want. Conclusion Keep in mind that this code will only work in WordPress 2.5 and above. The function_exists conditional tag will ensure that your theme doesn’t break, but nothing will appear in older versions. More information on other methods of using Gravatars is detailed in the WordPress Codex .
The Gravatar code Simply inserting the
-
- Posts: 22
- Joined: Sat Dec 21, 2024 3:37 am