Default Gravatar not showing for pings
Pergunta
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.
Solução
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.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a wordpress.stackexchange