Support » Themes and Templates » comments show wrong (only gravatar) avatars

  • I’m designing my own first theme in WordPress and I have a small problem. I want to use totally customized comment list, so I followed the WordPress Codex, and added a function to functions.php to do just that. It is as follows:

    function comment_theme($comment, $args, $depth) {
       $GLOBALS['comment'] = $comment; ?>
       <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
         <div id="comment-<?php comment_ID(); ?>">
          <div class="comment-author vcard">
    		 <?php echo get_avatar($comment,$size='81',$default='<path_to_url>' ); ?>
             <?php printf(__('<cite class="fn">%s:</cite>'), get_comment_author_link()) ?>
          <?php if ($comment->comment_approved == '0') : ?>
             <em><?php _e('Your comment is awaiting moderation.') ?></em>
             <br />
          <?php endif; ?>
          <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>" class="date">
    	  <?php printf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),'  ','') ?></div>
    	  <div class="comment-text">
          <?php comment_text() ?>
          <div class="reply">
             <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>

    Everyhting seems to be quite good, but the thing is that it alwasy gives me the gravatar icon, even if i have selected some other (like mystery man) from the settings page. Can anybody help me?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Delete
    in your get_avatar() function.

    That’s the bit messing up as the function thinks your specifying a custom image. It can’t find <path_to_url> so is erroring out by giving you the default. By deleting it it will give you the default set from the dashboard – in your case, mystery man.

    Thank you! I am using a custom theme designed by Artisteer and I couldn’t figure out why I was getting the standard blue and white ‘G” Gravatar when I had Mystery Man chosen in the Dashboard settings.

    Removing that bit of code solved the issue!

    I know this post is a little old, but this really helped me out and is still relevant for new users who install this plugin. Thanks!

    Thanks bsutcliffe, it was really helpfull.

    Im getting the same issue ussing an artisteer created theme however There is no code in functions.

    Under comments is this

    // Produces an avatar image with the hCard-compliant photo class
    function commenter_link() {
    	$commenter = get_comment_author_link();
    	if ( ereg( '<a[^>]* class=[^>]+>', $commenter ) ) {
    		$commenter = ereg_replace( '(<a[^>]* class=[\'"]?)', '\\1url ' , $commenter );
    	} else {
    		$commenter = ereg_replace( '(<a )/', '\\1class="url "' , $commenter );
    	$avatar_email = get_comment_author_email();
    	$avatar = str_replace( "class='avatar", "class='photo avatar", get_avatar( $avatar_email, 80 ) );
    	echo $avatar . ' <span class="fn n">' . $commenter . '</span>';

    The problem is theme related.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘comments show wrong (only gravatar) avatars’ is closed to new replies.