Random Posts in WordPress

Okay, there are plenty of places online with instructions on randomizing posts in WordPress; even WordPress tells how. But here's my version along with the code I used.

Basically, I randomized the loop, and this required replacing the standard loop like this:

Replace…

::CODECOLORER_BLOCK_1::

with…

::CODECOLORER_BLOCK_2::

That worked for me. (note: setup_postdata() prepares the $post array as if it had been part of a standard loop, and the code did not work without it)

Leave a Reply

Your email address will not be published.