How To Create A Page For Displaying Random Blog Posts In Your WordPress Site ?

Create a page displaying your random blog posts in your WordPress site.

Add this simple WordPress Loop that runs a query for displaying random posts and the number 1 in there is telling WordPress to only show 1 post. If you like you can change that number:

<?php
query_posts(array(‘orderby’ => ‘rand’, ‘showposts’ => 1));
if (have_posts()) :
while (have_posts()) : the_post(); ?>

<h1><a href=”<?php the_permalink() ?>”><?php the_title(); ?></a></h1>

<?php the_content(); ?>

<?php endwhile;
endif; ?>

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.