Support » Themes and Templates » How to display avatar in comments.php and single.php?

How to display avatar in comments.php and single.php?

  • I have enabled avatar in Settings > Discussion. But the avatar won’t show up at all, both in comment and in post. Only the default avatar (Mystery Man) showed up.

    I’ve tried those lines:

    <?php echo get_avatar( $id_or_email, $size = '96' ); ?>

    <?php echo get_avatar( $comment, 32 ); ?>

    <?php echo get_avatar( $id_or_email, $size, $default, $alt ); ?>

    But none of those work. Oddly, the avatar shows up properly in Twenty Ten theme, but not in other themes. Any help?

Viewing 2 replies - 1 through 2 (of 2 total)
  • <?php
    if ( function_exists( 'get_avatar' ) ) {
          echo get_avatar( $comment, 50);
       } else {
          //alternate gravatar code for < 2.5
          $grav_url = "http://www.gravatar.com/avatar.php?gravatar_id=
             " . md5($email) . "&default=" . urlencode($default) . "&size=" . $size;
          echo "<img src='$grav_url' height='50px' width='50px' />";


    @hush !
    i am using sociable.es’s facebook connect everything is working fine

    comment avatar showing in comment list but not in my footer widget

    how can i fetch avatar in my footer widget ?

    this is working when facebook comment
    <?php echo get_fb_avatar(get_comment_author_email(),get_comment_author_url()); ?>

    but gravatar not working, i used these all code

    <?php echo  get_avatar(get_comment_author_email($comment->comment_ID), 40); ?>
          <?php echo get_avatar(get_comment_author_email(), '37'); ?>
            <?php echo get_avatar(get_comment_author_url(), '37'); ?>

    i tried this plugin – recent comment with avatars
    it display all avatars fb or gravatar (working fine)

    but i dont want it as a plugin
    i want short code in widget
    if you can get idea from (http://pastebin.com/ZbMMbdtC) –
    i am not smart in php please help me

    please help me

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to display avatar in comments.php and single.php?’ is closed to new replies.