WordPress 2.5 Built In Avatars. Don’t Forget Echo!

One neat little feature of WordPress 2.5 is built in support for Gravatars via the get_avatar function. Simply use it in your theme’s comment loop in the comment.php file, and boom, you’ll have avatars. Nusuni Dot Com already supported Gravatars thanks to the plugin - but today I switched it over to the new function.

One little warning I’d like to pass along is make sure you use echo! While implementing it I did this:

<?php get_avatar($comment,64); ?>

There’s one big problem with that code - it doesn’t work! The solution to this problem was a simple programmer-error, I forgot echo! It took me almost thirty friggin minutes to figure that one out!

So yeah, make sure you use echo.

<?php echo get_avatar($comment,64); ?>

If this isn’t proof I’m an idiot, I don’t know what is.

Please subscribe, or else I will cry. Do you really want to make a programmer cry?

4 Comments

  1. Bart Says:

    It should be added to Murphy’s law. Simplest bugs always take the biggest amount of time to figure out :mrgreen:

  2. Jeremy Steele Says:

    Agreed. I suppose that is why many programmers work in teams - it makes it easier to find simple bugs. I’ve never been a big fan of team environments though. Unfortunately most code that is written by programmers looks worse than a doctor’s handwriting.

  3. Bart Says:

    Dude, I did not know that doctor’s handwriting is a global problem. The way they produce hieroglyphs is just amazing…

  4. Jeremy Steele Says:

    Haha. I feel bad for people who have to decipher that crap. My mom used to work at a few hospitals and medical centers - she couldn’t stand it when they wrote like a drunk monkey.

Leave a Reply

Note: By submitting your comment you agree to this blog's comment policy.

If you want a little icon next to your name - sign up for one at Gravatar.