Php 坚持在主页上添加评论

Php 坚持在主页上添加评论,php,html,wordpress,Php,Html,Wordpress,我一直在尝试在主页上的每个帖子下面添加两条最新的评论 当我这样做时,它会显示最新的回复(第一个),这些回复是针对之前的评论 这很令人沮丧,任何帮助都将不胜感激 global $post, $wp_query; $comment_args = array( 'orderby' => 'comment_count', 'post_id' => get_the_ID() ); $comment_array = get_comments($comment_args); $count = 1;

我一直在尝试在主页上的每个帖子下面添加两条最新的评论

当我这样做时,它会显示最新的回复(第一个),这些回复是针对之前的评论

这很令人沮丧,任何帮助都将不胜感激

global $post, $wp_query;
$comment_args = array( 'orderby' => 'comment_count', 'post_id' => get_the_ID() );
$comment_array = get_comments($comment_args);
$count = 1;
?>   
<?php if ($comment_array) {  ?>

<span class="comments-link">&#8226; 
<?php comments_popup_link(__('Be the first to comment!', 'encounters-lite'), __('1 Comment', 'encounters-lite'), __('% Comments', 'encounters-lite')); ?>
</span>
<span><?php _e( 'Discussion: ', 'encounters-lite' ); ?></span>
<span class="commentlist"></span>
<?php $comment_array = array_reverse($comment_array); ?>
<?php foreach($comment_array as $comment){ ?>
<?php if ($count++ <= 2) { ?>
全局$post,$wp\u查询;
$comment\u args=array('orderby'=>'comment\u count','post\u id'=>获取\u id());
$comment\u array=get\u comments($comment\u args);
$count=1;
?>   
• 
这是我正在编写的一段代码