Skip to content

Instantly share code, notes, and snippets.

@gasatrya
Created February 3, 2015 17:53
Show Gist options
  • Save gasatrya/0d65f2d489a16acfa93c to your computer and use it in GitHub Desktop.
Save gasatrya/0d65f2d489a16acfa93c to your computer and use it in GitHub Desktop.
WordPress recent comments w/ avatar
<?php
$comments = get_comments( array(
'number' => 5,
'status' => 'approve',
'post_status' => 'publish'
) );
?>
<?php if ( $comments ) : ?>
<ul>
<?php foreach( $comments as $comment ) : ?>
<li>
<a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
<span class="comment-avatar"><?php echo get_avatar( $comment->comment_author_email, '63' ); ?></span>
</a>
<a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
<strong><?php echo esc_attr( $comment->comment_author ); ?></strong>
<span><?php echo wp_html_excerpt( $comment->comment_content, '80' ); ?></span>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment