Cone Trees

Solution to query_posts(‘orderby=rand’) not working in WordPress

I had been wondering for a few months by now; why was it that I was able to display random posts in my downloads widget on my local server but not on the live site?

I was using <?php query_posts('orderby=rand'); ?> to do the job. The downloads widget on my website was supposed to display one random post from the download section and did so fine on the local server. But on my live site, instead of displaying a random post, it’d simply default to displaying the most recent post.

I did all I could and tried everything people suggested until I finally discovered, quite by accident, that it was the WP Sticky plugin that was causing the problem . I disabled the plugin and &rand began to work just fine on my live site! I was able to display random download posts just as I wanted to.

So, if you’ve tried everything possible under the sun to randomize your posts using <?php query_posts('orderby=rand'); ?>, and you use WP Sticky, then try disabling the plugin and check whether it makes your randomize post issue disappear.

Let me know if this this help you out too.