Show Off Your WordPress Archives With Random Posts
I have a couple of blogs with posts now in the hundreds. Some of them are timeless articles, but often visitors won’t go digging that deep. So I started searching for a way to make a “Random” selection on the sidebar, under archives or categories so they could sample across the board.
After looking at half a dozen plugins to do this, I was fustrated that it was so messy. Once I picked one I thought I could live with, I found that I had to rewrite my template too extensively, changing the loop and it just didn’t feel like a good idea for the future.
Then after alot of Googling, I found this gem on the WP hackers list:
Simply save that into your plugins and activate, then in your template files simple intercept a request for the “Random” category and inject a new list of posts before the loop with a simple call like: query_posts(‘random=true’)
Here’s a more full example: