How to Display Random WordPress Posts on a Page

Today we will learn a simple trick to show random articles on your website or blog powered by WordPress.
Simply create a new page and in code editor paste the below code and it will start showing random blog posts. This is a wonderful way on how to keep your visitors glued to your website, may be they have visited for a particular article, seeing this “stumble upon kinda” page they could learn more on your blog or niche and this might interest them to subscribe to your blog or stay more on your blog.

<?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; ?>

Hope this helped.
Cheers !!!