我的问题是,如何在 wordpress 的页面上显示随机评论?在我的网站上,我有一个 wp 页面,人们在其中留下很多评论,我希望它们随机显示,而不是按日期时间分类,这是分页评论的代码,我该怎么办?谢谢 :)
<?php foreach ($comments as $comment) : ?>
<li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>">
<div class="paginated-comments-number" style="float: left; color: #999; width: 30px; text-align: left;"></div>
<?php
if ( function_exists('get_avatar') )
echo get_avatar( $comment, 48 );
?>
<cite><?php comment_author_link() ?>
</cite>
<?php if ($comment->comment_approved == '0') : ?>
<em>Your comment is awaiting moderation.</em>
<?php endif; ?><br />
<small class="commentmetadata"><a href="<?php echo Paginated_Comments_URL('comment-' . get_comment_ID()); ?>" title=""><?php comment_date('F jS, Y') ?> at <?php comment_time() ?></a> <?php edit_comment_link('edit',' ',''); ?></small>
<?php comment_text() ?>
</li>
<?php
/* Changes every other comment to a different class */
$oddcomment = ( empty( $oddcomment ) ) ? 'class="alt" ' : '';
?>
<?php endforeach; /* end for each comment */ ?>
</ol>
<p>
<!-- Start Paginated Comments Pages -->
<?php if ( Paginated_Comments_have_pages() ) : ?>
</p>
<p>
<?php endif; ?>
<!-- End Paginated Comments Pages -->
<?php else : // this is displayed if there are no comments so far ?>
<?php if ('open' == $post->comment_status) : ?>
<!-- If comments are open, but there are no comments. -->
<?php else : // comments are closed ?>