Rss Feed
Tweeter button
Facebook button

Manually Display Random Posts in Wordpress

Sometimes new visitors will visit your blog and only see the most recent articles. I believe its a good idea to give the readers some older articles that you’ve written. Along with discovering more content on your site, inserting a random post on the sidebar will increase page views.

To add random posts to your sidebar go to Appearance–>Editor–>sidebar.php. Then, insert the following code:

<li><h2>Random Post</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>
</li>

To change the number of posts the code displays, just change the blue # to how many posts you want. 

Related posts:

  1. 25 of the Best Widgets For Blogger
  2. How To Set Correct Permalinks In Wordpress
  3. How to Install a New Wordpress Theme
, , , ,

Leave a Reply