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> <ul> <?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 } ?> </ul>