random post ceases to be random at subsequent refresh
-
<?php $args = array( 'posts_per_page' => 1, 'orderby' => 'rand' ); $rand_posts = get_posts( $args ); foreach ( $rand_posts as $post ) : setup_postdata( $post ); ?> <?php the_content(); ?>
Wrote this a couple of months ago, in line with some advice I got from documentation&forums, with the intention to display the content of a random post – and it worked.
The thing is though I am now noticing that the “randomness” only applies to the first time I visit my site – not at subsequent refresh.
That is, no matter how many times I refresh my site, I get the same post, that was originally loaded as random.
Obviously, my question is: Why is this happening?
I’m thankful for all the help I can get.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘random post ceases to be random at subsequent refresh’ is closed to new replies.