嗯,我想不出来,但我的兄弟,他非常擅长PHP,确实想出来了。他自己并不认为这是最好的解决方案,但嘿,这是可行的。也许是一个他并不自豪的快速解决方案,但我得救了!;-)他甚至好心地评论了他的工作。我希望其他人也能用这个!
<?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,
\'group\' => \'post_id\'
);
$comments = get_comments($args);
// Due to wordpress not having a common functionality, we create a new list of comments manually
$filteredComments = array();
// Posts we already have a comment for
$filteredUsedPosts = array();
// Amount of comments
$filteredCommentLimit = 5;
// Loop through all comments
foreach($comments as $comment) {
// Have we reached our amount of coments, then weŕe finished
if (count($filteredComments) < $filteredCommentLimit){
// Do we already have comment for this post?
if (!in_array($comment->comment_post_ID, $filteredUsedPosts)){
// We add the POST ID to the list of used POST IDs
$filteredUsedPosts[] = $comment->comment_post_ID;
// We add our comment to the display comments list
$filteredComments[] = $comment;
}
}
}
foreach($filteredComments 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;
?>