Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $comments = get_comments( array( 'number' => 10 ) );
- if ( !empty( $comments ) ) {
- ?>
- <ul>
- <?php foreach ( $comments as $comment ) : ?>
- <li><?php echo sprintf(
- "<strong>%s</strong> on <a href="%s">%s</a> : "%s" — <a href="%s">view</a>",
- $comment->comment_author,
- get_the_permalink( $comment->comment_post_ID ) . "#comment-" . $comment->comment_ID,
- get_the_title( $comment->comment_post_ID ),
- mb_strlen( $comment->comment_content ) > 100 ? mb_substr($comment->comment_content, 0, 100) . " .." : $comment->comment_content,
- get_the_permalink( $comment->comment_post_ID ) . "#comment-" . $comment->comment_ID
- ); ?></li>
- <?php endforeach; ?>
- </ul>
- <?php
- } else {
- echo sprintf("<p>%s</p>", "No comments were found.");
- }
Add Comment
Please, Sign In to add comment