You have thousands of posts at your aged WordPress site, now you would like to randomly display them at your main page.

To shuffle your posts, follow this guide:

1. Login to FTP account of your WordPress website.
2. If you are located in root (public_html), go to wp-content/themes/mywordpresstheme folder.
3. Search for index.php and open it with your text editor.
4. Look for the line that contains:

<?php while (have_posts()) : the_post(); ?>

5. Before that line or code, copy the following code:

<?php query_posts($query_string . '&orderby=rand') ?>


6. Save and replace existing index.php with customized one.

You are done, posts at home page should be now displaying randomly.

Each time you refresh the blog.

11 Comments

  1. I have been looking for that for quite some time … THANK YOU!!!

  2. thehandsomenerd

    WordPress official says that wordpress does not allow FTP access to any blogs.

    Help!

  3. Thank you very much for this code, working perfect.
    Could this cause damages to SEO?
    regards

    • I am quite sure this won’t do any damage to your blog in the matter of SEO. This will just randomly display your posts.

      In case you don’t have time to post fresh content ;)

  4. Gr8, now all my posts are shown randomly. Very nice.

  5. I am trying these instructions but the I can’t find the line mentioned in item #4. I have wordpress 3.4.2 and have an autofocus theme 2.02. Where else might it be? Thanks in advance!

  6. Dr. Peter Hartig

    I´ve been searching Google for days for this awesome piece of code. Thank you very much. My blog runs absolutely perfect. I have WordPress 3.5.2 with theme stay pressed.

  7. while randomly display wordpress posts or shuffle them. . . if we want shuffling posts after a specific time then what we have need to do. . .?

  8. Manpreet Arora

    Thnx a lot buddy…

  9. Hi do you happen to know if its possible to randomize posts one time then return to date order?

    I ask because I plan to populate my site with orderly data then you like to shuffle this prior to launch and returning to normal.

    Many thanks.

Related Posts