我需要帮助,在每次刷新页面时显示不同的随机帖子。
我正在使用orderby = rand函数,但这在我拥有的每个博客文章中给了我相同的随机文章。我需要在每个页面刷新时都有不同的帖子,不确定如何实现。
我目前有以下代码:
<div class="container">
<div class="ltblg text-center">Related Posts</div>
<div class="row">
<?php
$args = array( 'posts_per_page' => '3','order'=>'ASC','orderby'=>'rand' );
$recent_posts = new WP_Query($args);
while( $recent_posts->have_posts() ) :
$recent_posts->the_post()
?>
<div class="col-md-4 ">
<div class="blgbox">
<div class="latebog">
<?php
if (has_post_thumbnail()) {
the_post_thumbnail();
} else {
echo "<img src='/wp-content/uploads/2018/04/bydeaulfblog.png'/>";
}
?>
</div>
<div class="blogheading blglist relttle">
<a href="<?php echo get_permalink(); ?>">
<?php echo wp_trim_words( get_the_title(), 15 ); ?>
</a>
</div>
<div class="blgdate text-uppercase">
<?php the_time('F jS, Y') ?>
</div>
<div class="blgtet">
<p>
<?php echo wp_trim_words( get_the_content(), 25, '...' );?>
</p>
</div>
<a href="<?php echo get_permalink(); ?>" class="blgrdbtn">Read More
<span><img src="/wp-content/uploads/2018/03/rightarrw.png" /></span>
</a>
</div>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata();
# reset post data so that other queries/loops work
?>
</div>
</div>
谢谢!