I am trying to make a custum 'Recent Comments' code for use in the sidebar. I have come a long way, but there is just one thing that doesn't do what I'd like it to do.
What I want is that, per page with comments that is found, only the last comment is shown. I was hoping post_per_page would do the trick, but it doesn't!
This is my code:
<?php
$args=array(
'author_email' => '',
'ID' => '',
'karma' => '',
'number' => 5,
'offset' => '',
'orderby' => 'comment_date_gmt',
'order' => 'DESC',
'parent' => '',
'post_id' => '',
'post_author' => '',
'post_name' => '',
'post_parent' => '0',
'post_status' => 'publish',
'post_type' => 'page',
'posts_per_page' => 1,
'status' => 'approve',
'type' => '',
'user_id' => '',
'search' => '',
'count' => false
);
$comments = get_comments($args);
foreach($comments as $comment) :
?>
<div style="border: 0px solid #000000; height: 1%; overflow: hidden;">
<div style="border: 0px solid #000000; float: left; width: 28%;">
<a href="<?php echo get_author_posts_url($comment->user_id); ?>"><?php echo get_avatar( $comment, 48 ); ?></a>
</div>
<div style="border: 0px solid #000000; float: right; width: 72%;">
<?php
$aantalcomments = get_comments_number( $comment->comment_post_ID );
?>
<a href="<?php echo get_author_posts_url($comment->user_id); ?>"><?php echo($comment->comment_author) ?></a> op:<br>
<a href="<?php echo get_comment_link($comment->comment_ID); ?>">
<?php
echo($comment->post_name . " (" . $aantalcomments . ")<br>");
?>
</a>
<?php
echo get_comment_date(' l, j F, Y ', $comment->comment_ID);
?>
</div>
</div>
<hr>
<?php
endforeach;
?>
