WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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

Here is my comments block:

<div id="comments">
    <?php if (have_comments()) : ?>
        <h3><?php printf(_n('1 comment', '%1$s comments', get_comments_number()), number_format_i18n( get_comments_number() ), '' ); ?></h3>
        <div class="comment_list">

            <?php $comments_by_type = &separate_comments($comments); ?>
            <?php if ( !empty($comments_by_type['comment']) ) : ?>
                <?php wp_list_comments(array('callback' => 'commentslist', 'type' => 'comment')); ?>
            <?php endif; ?>

            <?php if ( ! empty($comments_by_type['pings']) ) : ?>
            <h3 id="pings">Pingbacks/Trackbacks</h3>
            <ol class="pinglist">
            <?php wp_list_comments(array('callback' => 'commentslist', 'type' => 'pings')); ?>
            <?php endif; ?>
    <?php endif; // end have_comments() ?>

Here is my wp_list_comments callback:

function commentslist($comment, $args, $depth) {
    $GLOBALS['comment'] = $comment;
        require_once(ABSPATH . WPINC . '/registration.php');
        if ($comment->user_id || email_exists($comment->comment_author_email)){
            //comment by registered user
            $avatar = '/images/bird_comments_big.png';
            //comment by none registered user
            $avatar = '/images/bird_comments_pink.png';
        <div id="comment-<?php comment_ID(); ?>" <?php comment_class(); ?>>
                        <?php echo get_avatar($comment, 70, get_bloginfo('template_url').$avatar); ?>
                        <div class="comment-meta">
                            <?php printf(__('<p class="comment-author"><span>%s</span> says:</p>'), get_comment_author_link()) ?>
                            <?php printf(__('<p class="comment-date">%s</p>'), get_comment_date('M j, Y')) ?>
                            <?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
                        <div class="comment-text">
                            <?php if ($comment->comment_approved == '0') : ?>
                                <p><?php _e('Your comment is awaiting moderation.') ?></p>
                            <?php endif; ?>
                            <?php comment_text() ?>

It seems to that wp_gravatar should call up the non-registered user image due to a lack of an e-mail address for pings, but instead its returning nothing.

share|improve this question
up vote 1 down vote accepted

By default WordPress does not display an avatar for a pingback or a trackback - do they even contain an e-mail address? You can add these to the get_avatar_comment_types filter if you want to change this.

share|improve this answer
They don't, but that third param I pass to get_avatar sets a default gravatar for straight comments without emails, so I assumed... – two7s_clash Apr 26 '11 at 17:06
@two7s_clash: Ah, then you can just check the output of get_avatar, and if it is false, use your default avatar. – Jan Fabry Apr 26 '11 at 18:31

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.