Created
February 17, 2015 08:53
-
-
Save schalkburger/b4e9ecc5d4b8e1e57da8 to your computer and use it in GitHub Desktop.
Wordpress display comments
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 // Display latest comments for each post on non-single page views | |
$comment_array = array_reverse(get_approved_comments($wp_query->post->ID)); | |
$count = 1; // Number of comments to display | |
if ($comment_array) { ?> | |
<h3><?php comments_number('No comment', '1 comment', '% comments'); ?></h3> | |
<ul> | |
<?php foreach ($comment_array as $comment) { | |
if ($count++ <= 2) { ?> | |
<li><?php comment_author_link(); ?>: <?php comment_excerpt(); ?></li> | |
<?php } | |
} ?> | |
</ul> | |
<?php } else { | |
echo '<p>No comments yet.</p>'; | |
} ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment