WordPress.org

Forums

The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

How to display avatar in comments.php and single.php? (3 posts)

  1. Xaliber
    Member
    Posted 5 years ago #

    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?

  2. hush_hush
    Member
    Posted 5 years ago #

    <?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' />";
       }
    ?>

    IT SHOULD WORK

  3. yashmistrey
    Member
    Posted 5 years ago #

    @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
    http://pastebin.com/ZbMMbdtC
    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

Topic Closed

This topic has been closed to new replies.

About this Topic