[wp-hackers] How to display random post with next and previous links alphetically showed

Claude Needham gxxaxx at gmail.com
Tue Jul 12 21:19:43 UTC 2011


On Tue, Jul 12, 2011 at 11:44 AM, Otto <otto at ottodestruct.com> wrote:
> Ahh, yes. Of course that doesn't work. SQL doesn't work that way.
> Well, the only thing I can think of is to sort the $wp_query->posts
> manually after getting the random list.

It might help that you don't have to fully sort the list.
All that should be required is to traverse the list looking for the
post that is less than the rand post but greater than any other post
which is also less. In addition find any post that is greater than the
rand post but less than all other posts which are greater.

So a single loop through the titles should give you want you need.

Regards,
Claude


More information about the wp-hackers mailing list