Dukeo » WordPress » Random Post Order: How To Display Your Posts In A Random Order

Random Post Order: How To Display Your Posts In A Random Order

Steven 4 responses WordPress

There are several reasons why you could want to display your WordPress blog posts in a random order… It could be because you are building your portfolio, a CSS gallery, a Flash Games website, a Video Website… Displaying your WordPress blog posts in a random order is a very simple trick to achieve.

If you want to randomize posts order on your homepage, you must edit your index.php theme file.

Search for:

if (have_posts()) :

And replace it with:

query_posts('orderby=rand');
if (have_posts()) :

You might also want to randomize posts in your category archives. If that’s the case, you must edit your archive.php file (the steps are the same as above).

If you enjoyed this article,
Get email updates

Join for Free »

4 Comments

  1. Pt

    It worked, but now put my posts on every page…can you maybe include a screen shot before and after..thanks!

    1. You can’t really use random order and pagination together. You will see the same posts on different pages.

  2. All Of Themes

    Short tip but really really helpful . I will try on my page and i will tell you if help me out! I have been searching this long time ago . You save me 2 days searching thru internet! Thanks dude! :)))

  3. Aldo

    Thank you so much! :)