WordPress: Display random posts

You will often find that when you get going with your blog and really start to build up your posts, that the older posts start to get buried and have less exposure. Most people will pick up the more recent posts and will not bother scrolling back a looking at your older posts. A great way to give your older blog posts more exposure and to grab the attention of your users and keep them on your site is to have a random posts list in your sidebar.

Due to the natural structure of blogs, articles end up being buried down once they get old. Most new users join and pick up from the moment they join, and they never bother going back to one of your good posts. One of the easiest way to give a new life to your older posts is by displaying them in the sidebar. In this tutorial, we will share how you can display random posts in your WordPress.

All you have to do is open your sidebar.php, or any other file you like to add it in and paste the following code:

<h2>Random Posts</h2>
	<?php $posts = get_posts('orderby=rand&numberposts=5'); foreach($posts as $post) { ?>
		<li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
	<?php } ?>
Free Graphics, Icons, Tutorials
Free Graphics Free Christmas Vector Icon Graphics Pack 2017Free Fitness Vector Icons Graphics PackFree Camping Vector Graphics PackFree Summer Graphics PackFree File Icon PackFree Fast Food Vector Graphics
Sharing is caring...
Like & Follow
Share the love, share this page! Facebook Twitter Digg Reddit LinkedIn Pinterest Email
Close [X]
The Web Taylor
1000 Lakeside North Harbour Portsmouth, Hampshire PO6 3EN
02392 123358