• oste15

    (@oste15)


    Alright I am hoping this is a simple fix. I am trying to simply add a gravatar to my authors pages. The issue is with the code I have the gravatar shows up just as many times as the number of posts the author has.

    You can see what I mean here:
    author a:http://www.aquaculturetalk.com/author/seacucumber/
    author b:http://www.aquaculturetalk.com/author/mike/

    This is the code:
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php echo get_avatar( get_the_author_email(), ’80’ ); ?>
    <?php endwhile; else: ?>
    <p><?php _e(‘Sorry, no posts matched your criteria.’); ?></p>
    <?php endif; ?>

    I am using the loop in another section of the page, but I am hoping I can just modify this code to make the gravatar show up only once.

Viewing 3 replies - 1 through 3 (of 3 total)
  • yakuphan

    (@yakuphan)

    Change this,

    <?php $first_author = 0; ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php
      if ($first_author == 0) {
       echo get_avatar( get_the_author_email(), '80' );
     }
     $first_author = 1;
    ?>
    <?php endwhile; else: ?>
    <?php _e('Sorry, no posts matched your criteria.'); ?>
    
    <?php endif; ?>

    Could you share your author archive?

    Thread Starter oste15

    (@oste15)

    Hey, thanks that did the trick.

    This is the tutorial from Justin Tadlock that I used to create the browse by authors page.

    http://justintadlock.com/archives/2008/06/09/doing-more-with-gravatars-authors-template-page

    The tutorial from my site you linked to is about creating an Authors page template that lists all authors. It has nothing to do with the author archive template.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Create authors page with gravatar using the loop’ is closed to new replies.