• Hello,

    I’ve successfully used the “orderby=rand” argument to create a random listing of a single category on a page. To be more specific, the category is “Member” and the page is a list of the title and a custom field for member profiles. My problem is, there are currently 58 members, and more are expected to join (probably no more than 150 or so), and I would like to split these member excerpts across multiple pages.

    Unfortunately, as you know, with the “orderby=rand” argument alone, there is no guarantee that subsequent pages won’t repeat posts, as it re-randomizes each page without taking into account what’s already been displayed. So my question is, how do I randomize my posts across multiple pages? If I’m not making sense, this person described the exact same problem.

    I’ve searched the forums and found the suggestion that I replace <?php query_posts('orderby=rand'); ?>' with `<?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
    query_posts($query_string.’&orderby=rand&paged=’,$paged); ?>`, but it didn’t work for me.

    I also Googled the problem and found a general PHP solution: $offset_result = mysql_query( " SELECT FLOOR(RAND() * COUNT(*)) ASoffsetFROMtable` “);
    $offset_row = mysql_fetch_object( $offset_result );
    $offset = $offset_row->offset;
    $result = mysql_query( ” SELECT * FROM table LIMIT $offset, 1 ” );`

    But I don’t really understand WordPress, PHP, or MySQL well enough to know if I can utilize that, and if I can, how to utilize it.

    Thanks for taking the time to consider my query.

    Scott

Viewing 1 replies (of 1 total)
  • Hi Scott,

    I`m looking for the exact same thing.

    Did you have any luck with this problem?

    I posted the same question on stackoverflow and I got a smart but difficult answer, which you can try.

Viewing 1 replies (of 1 total)
  • The topic ‘Random posts over multiple pages’ is closed to new replies.