is this possible? random posts while paged (2 posts)

  1. takispap
    Posted 4 years ago #

    Hi there,

    i`m building a gallery with a few houndred artworks (custom posts) and I wonder if I can have them displayed randomly and paged at the same time.

    With the following code when each page reloads the posts change possitions and some reappear in multiple pages.

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array('post_type' => 'artworks', 'orderby'=>rand, 'paged'=>$paged, 'posts_per_page' => 60);

    Is it possible to first randomise their possition and then divide them into pages (but to keep their possition for current session)?

    Can this be done with wp-pagenavi? Any ideas?

  2. benetic
    Posted 4 years ago #

    to share my own experience, i can tell you that I have tested the same approach on one of my websites where i need to randomly display some posts.

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $arg = array (   'cat'=>133,
    $wp_query = new WP_Query( $arg );

    I was faced with one issue doinf this : with the RAND parameter, the query did NOT display all posts. strangely, it was displaying some posts twice, while not displaying some others...
    Strange also was the fact that the total number of displayed posts was the same as the expected total post from the database : it took me some days before detecting the issue.
    I haven't fixed this issue yet : if anyone has a clue ...

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic