WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on a plugin for showing users via shortcode by their role (in this site's case - authors). I'm getting a list of user objects using a WP_User_Query statement, then creating the output for each user like this:

foreach ( $users as $user ) { ?>

            <div class="sap_author_box">

                <div class="sap_author_pic"><?php get_avatar( $user->user_email, 150 ); ?></div>
                <div class="sap_author_name"><?php
                    echo '<a href="http://curbcollege.org/happytogethertour/author/' . $user->user_login . '">' . $user->display_name . '</a> <span class="smallertext">( ' . $user->age . ' ) - ' . $user->classification . ' from ' . $user->hometown . '</span><br />';
                    echo '<span class="smallertext">Major: ' . $user->major;
                    echo ( empty( $user->minor ) ? '</span>' :  ', Minor: ' . $user->minor . '</span>' ); ?>
                <div class="sap_author_bio"><?php echo $user->user_description; ?></div>


        <?php } // End of $users foreach

All the data from the user's profile comes out just fine, except the avatar. I've tried using $user->ID instead of email, but that doesn't work either. I know both the email and ID are called correctly because I can echo them onto the page and see them, so it's not that the data isn't getting to the get_avatar function. What am I doing wrong with get_avatar? I know some of the authors have avatars because I can see them on the Users list, but not on the output page. Ideas?

share|improve this question
up vote 0 down vote accepted

You forgot to echo it:

<?php echo get_avatar( $user->user_email, 150 ); ?>
share|improve this answer
Good grief. The simple things... :) I've looked at a bunch of tutorials on using get_avatar and didn't notice the echo statement on any of them. Thanks Eugene! – Slushman Jun 8 '12 at 15:22
you are welcome :) – Eugene Manuilov Jun 8 '12 at 15:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.