I am trying to add a button to take the viewer to a random post. Below’s the code I am using:-
<?php query_posts(array('orderby' => 'rand', 'posts_per_page' => 1));
if (have_posts()) :
while (have_posts()) : the_post(); ?>
<div class="post-lot">
<a href="https://wordpress.stackexchange.com/questions/303129/<?php the_permalink() ?>">Yes, Robo! Take me there.</a>
</div>
<?php endwhile;
endif; ?>
But, it keeps showing two links. If I change posts_per_page
to 2, it shows 3 links. I tried adding wp_reset_query
but the issue still persists.