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.


1 Answer 1


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.

  • They don't, but that third param I pass to get_avatar sets a default gravatar for straight comments without emails, so I assumed... Apr 26, 2011 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, 2011 at 18:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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