Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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']) ) : ?>
            <ol>
                <?php wp_list_comments(array('callback' => 'commentslist', 'type' => 'comment')); ?>
            </ol>
            <?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')); ?>
            </ol>
            <?php endif; ?>
        </div>
    <?php endif; // end have_comments() ?>
    </div>

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';
            }else{
            //comment by none registered user
            $avatar = '/images/bird_comments_pink.png';
            }
        ?>
    <li>
        <div id="comment-<?php comment_ID(); ?>" <?php comment_class(); ?>>
            <table>
                <tr>
                    <td>
                        <?php echo get_avatar($comment, 70, get_bloginfo('template_url').$avatar); ?>
                    </td>
                    <td>
                        <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>
                    </td>
                    <td>
                        <div class="comment-text">
                            <?php if ($comment->comment_approved == '0') : ?>
                                <p><?php _e('Your comment is awaiting moderation.') ?></p>
                                <br/>
                            <?php endif; ?>
                            <?php comment_text() ?>
                        </div>
                    </td>
                </tr>
            </table>
         </div>
<?php
}

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
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.