Forums

Trying to show avatar along with comments in widget (4 posts)

  1. sesaconsulting
    Member
    Posted 1 year ago #

    Hey folks:

    I have creted a widget that displays the most recent comments of my posts. I am trying to figure out how I can have it display the users' avatar in addition to the comments.

    Here the link: http://www.howistyle.info (It is the members feed widget).

    And here is the code I am using:

    <?php $recent = new WP_Query("cat=17&showposts=1");
    while($recent->have_posts()) : $recent->the_post();?></p>
    <p><?php $comments = get_comments('post_id=' . $post->ID . '&number=5');
    if($comments) {</p>
    <p>foreach($comments as $comment) :
    echo($comment->comment_author .
    ' says: ' . $comment->comment_content . '</p>
    <p>') ; endforeach;
    } ?>
    <?php endwhile; ?>

  2. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

  3. sesaconsulting
    Member
    Posted 1 year ago #

    Thanks Esmi. My bigger question now, is where in my code do I put following?:

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

  4. sesaconsulting
    Member
    Posted 1 year ago #

    I added it and it gave me one avatar for the first comment. I am not sure how to add it so that it shows the avatar for each comment.

Topic Closed

This topic has been closed to new replies.

About this Topic