Solution

Place the code bellow in functions.php file inside your theme’s folder.

function randomPosts($numPosts = 5){

	query_posts(array('orderby' => 'rand', 'showposts' => $numPosts));
	?> <ul> <?php
	if (have_posts()) : while (have_posts()) : the_post();

	?>
			<li><a title="Permanent Link to <?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>

		<?php

	endwhile;

	?> </ul> <?php

	endif;

	wp_reset_query();

}

Change the layout to fit your needs.

Calling randomPosts(); will show 5 random posts and if you want a different amount then call it like randomPosts(number);

Our WordPress themes
We have a few WordPress themes that we would like you to take a look at if you want.
check out the portfolio