Just before ‘the loop‘ of a WordPress site, you would normally use query_posts(). Not only does this set a global variable somewhere deep inside the WordPress core to an array of posts but it also returns a reference to that array. This is pretty useful if you want to manipulate it before ‘the loop’. A good example of this is randomising the array, like I have with the last 3 posts on the home page of this site.
You can do this by simply wrapping the query_posts() call in a shuffle:
<?php
shuffle(query_posts()); // query_posts() will probably have some parameters passed to it. That's ok.
?>
shuffle(query_posts()); // query_posts() will probably have some parameters passed to it. That's ok.
?>
<?php
$posts =& query_posts(); // query_posts() will probably have some parameters passed to it. That's ok.
shuffle($posts);
?>
$posts =& query_posts(); // query_posts() will probably have some parameters passed to it. That's ok.
shuffle($posts);
?>


