make pagination work for random list

This topic contains 1 reply, has 2 voices, and was last updated by  Stiofan O’Connor 8 years, 5 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #217907

    BL Interactive
    Expired Member
    Post count: 83

    Issue:
    random listings pagination is all over the place. places show up on multiple pages, if someone goes back to page 1 it’s a whole different listing. I’ve tried many approaches. My client needs this to work.

    Request:
    Have random lists cached for 5 minutes, either site-wide, or user based.

    Considerations:
    – needs to be upgrade friendly
    – The site is hosted on WPengine and uses EverCache

    I have made this work for regular posts on other sites before. Maybe a jumping off point.

    
    
    session_start();
    
    add_filter('posts_orderby', 'edit_posts_orderby');
    
    function edit_posts_orderby($orderby_statement) {
    
        $seed = $_SESSION['seed'];
        if (empty($seed)) {
          $seed = rand();
          $_SESSION['seed'] = $seed;
        }
    
        $orderby_statement = 'RAND('.$seed.')';
        return $orderby_statement;
    }
    #218414

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hello,

    There was talk of when sort is random just having a link saying more random and just to refresh the page, would this solve your issue?

    Stiofan

Viewing 2 posts - 1 through 2 (of 2 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount