Forums

Post repetition when using 'orderby=rand' (2 posts)

  1. chips
    Member
    Posted 9 months ago #

    I know a lot of people are aware of this problem, and I think it's something that really needs looked at for an upcoming release.

    Currently if I have 100 posts, split them over 10 pages and order them randomly, the same post can appear several times through the pages. Now this might not seem like a huge issue but the big part of this problem is that not all posts are displayed. This is because of the repeated posts.

  2. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 9 months ago #

    I use this:

    <?php $do_not_duplicate[] = get_the_ID(); ?>

    to prevent duplication between my slide show and post sections.

    Kinda works like this:
    $loop = new WP_Query( array( 'cat' => $category, 'posts_per_page' => 11, 'post__not_in' => $do_not_duplicate ) );

Reply

You must log in to post.

About this Topic