WordPress.org

Ready to get started?Download WordPress

Forums

comments show wrong (only gravatar) avatars (6 posts)

  1. ragulka
    Member
    Posted 4 years ago #

    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()) ?>
          </div>
          <?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>
    
          <div class="reply">
             <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
          </div>
         </div>
    <?php
            }

    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?

  2. Ben Sutcliffe
    Member
    Posted 4 years ago #

    Delete
    ,$default='<path_to_url>'
    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.

  3. J-Reese
    Member
    Posted 4 years ago #

    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!

  4. Jakets
    Member
    Posted 4 years ago #

    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!

  5. Psychonaut
    Member
    Posted 4 years ago #

    Thanks bsutcliffe, it was really helpfull.

  6. ghostofanonion
    Member
    Posted 4 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic