Created
February 3, 2015 17:53
-
-
Save gasatrya/0d65f2d489a16acfa93c to your computer and use it in GitHub Desktop.
WordPress recent comments w/ avatar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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