我在一个网站上工作是一个客户端想要显示一个随机的证书,刷新时旋转。正在使用的推荐仅仅是人们留下的评论。所以,我非常喜欢拉动评论摘录,但我无法得到它随机评论,它只是拉最新的。有没有办法做到这一点?这是我正在使用的代码:WordPress的评论
<?php
$args = array(
'status' => approve,
'number' => 1,
'orderby' => 'rand',
);
$comments = get_comments($args); ?>
<h3 class="side-heading">Customer Tesimonials</h3>
<div class="testimonials-inner">
<div class="testimonials-inner-inner">
<?php foreach ($comments as $comment) { ?>
<p><?php
$title = get_the_title($comment->comment_post_ID);
echo get_avatar($comment, '53');
//echo '<span class="recommauth">' . ($comment->comment_author) . '</span>';
?>"<?php
echo wp_html_excerpt($comment->comment_content, 72); ?>"
</p>
<?php } ?>
<br />
<a class="re" href="/"><h4 class="butt-sub">Tell Your Story</h4></a>
</div>
</div>
</div>
</div>
谢谢!
乍一看,代码看起来很好。尝试禁用插件。已知WP Sticky会导致问题。 –
http://codex.wordpress.org/Function_Reference/get_comments - “order”的有效值仅为“ASC”和“DESC”。 – artlung