坚持在主页上添加评论

时间:2015-03-07 13:23:02

标签: 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;
?>   
<?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) { ?>

这是我正在处理的一段代码。

0 个答案:

没有答案