Randomize posts but keep pagination (1 post)

  1. Kennedy808
    Posted 4 years ago #

    My site is a directory of other websites, which I want to display in a random order to give all the listings equal exposure.

    Currently, I'm using <?php if ( is_home() ) { query_posts('orderby=rand'); } ?> right before the<?php if (have_posts()) : while (have_posts()) : the_post(); ?> line which works fine as long as all the posts are on one long page.

    I have about 25 listings now, and if I set it to 10 posts per page for example, then I get 10 random on the first page, but then on the second page I get 10 more pulled from the entire list of 25, rather than from the 15 not displayed on the first page. So there are duplicates between the pages.

    Is there a way to have it randomize all the listings, but then remember that order across the pages so each post is only displayed once per page?


Topic Closed

This topic has been closed to new replies.

About this Topic