How to Display WordPress Random Post in your Theme

On 31 Aug, 2014 By With 0 Comments

If you’re blogging for some time now, you might notice that your old post are being forgotten and rotten in the very end of your website. Why not give them another chance to shine by randomly displaying your old post from your sidebar, you can try to use this on your custom WordPress theme. Today, we will learn how to display WordPress random post in your theme, this will be a very straight forward tutorial.

wordpress random post How to Display Wordpress Random Post in your Theme

Start by opening your dashboard > appearance >editor and open your sidebar.php, now, add this piece of code.

This will display 5 random WordPress post, if you want to change it you can edit this part numberposts=5 and change the number to how many you wanted to display. You can also change the image according to your liking, I set my post-thumbnails to category-thumb because that’s the name of my thumbnails.

You can play around with the CSS to match your theme, here’s a simple styling that I did.

If you’re the type that doesn’t want to touch the code, there’s other alternative plugin that you can use.

WordPress random post plugin

Spider Random Post

random wordpress post How to Display Wordpress Random Post in your Theme

Spider Random Post allows you to show posts in a random order in a sidebar. You can display simultaneously as many random posts as you need.

Advanced Random Posts Widget

random wordpress post2 How to Display Wordpress Random Post in your Theme

Provides flexible and advanced random posts widget. Allows you to display them with thumbnails, post excerpt, multiple category and more.

Random Posts Widget

random wordpress post3 How to Display Wordpress Random Post in your Theme

Random Posts Widget Configurable

random wordpress post4 How to Display Wordpress Random Post in your Theme

Hope this will be useful to you as it did to me. I used this code on my 404 page, so users who end up on the said page can see random post and Googlebot can index my old post, which is cool!

If you have more suggestion like this WordPress random post, you can hit me up in the comments below for questions.

Leave a Reply