Skip to content

Instantly share code, notes, and snippets.

@satrya

satrya/comments.php

Created Feb 3, 2015
Embed
What would you like to do?
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