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

Otto otto at ottodestruct.com
Tue Jul 12 18:44:44 UTC 2011


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.

-Otto



On Tue, Jul 12, 2011 at 1:30 PM, Deepak Mittal <dpac.mittal2 at gmail.com> wrote:
> Doesn't work. Everything is in random order. Any other solution?
>
> On Tue, Jul 12, 2011 at 7:39 PM, Otto <otto at ottodestruct.com> wrote:
>
>> I haven't tried it, but from a quick glance at the query code, this might
>> work:
>>
>> query_posts(array('orderby'=>'rand title'));
>>
>> There's a single space between rand and title. So you'll get random
>> posts which should then be ordered by the title.
>>
>> -Otto
>>
>>
>>
>> On Tue, Jul 12, 2011 at 7:57 AM, Deepak Mittal <dpac.mittal2 at gmail.com>
>> wrote:
>> > Hi guys,
>> >
>> > I am trying to display a random post on homepage using
>> >  query_posts('orderby=rand')
>> >
>> > The problem is I want to display the next and previos post links
>> > alphabetically. That is to say, if I have posts with following titles:
>> >
>> > Apple
>> > Ball
>> > Cat
>> > Dog
>> >
>> > And if Cat is chosen as random post, the next and previous link should
>> show
>> > Dog and Ball respectively. Any help for achieving this would be highly
>> > appreciated.
>> >
>> > --
>> > Regards,
>> > Deepak Mittal,
>> > Twitter - @dpacmittal
>> > _______________________________________________
>> > wp-hackers mailing list
>> > wp-hackers at lists.automattic.com
>> > http://lists.automattic.com/mailman/listinfo/wp-hackers
>> >
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>
>
>
> --
> Regards,
> Deepak Mittal,
> Twitter - @dpacmittal
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list