- This topic has 1 reply, 2 voices, and was last updated 9 years, 8 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
These forums are now closed and remain for historical purposes.
None of the content applies to the new version 3. For support, get in touch via our contact form.
Forums › Forums › Search & Filter Pro › sort results in random order carry over on multiple pages
Tagged: randomisation
I have selected to default sort the results of a search in ‘random’ order.
The issue is when I have multiple page results the page re-randomises it on reload so some results are show multiple times and some not at all. I understand this is a wordpress query issue.
I have found some code that should work, by storing the value in a session seed() however, it stops the randomisation completely.
This is my code:
session_start();
add_filter(‘posts_orderby’, ‘edit_posts_orderby’);
function edit_posts_orderby($orderby_statement) {
if( !is_admin() ) {
$seed = $_SESSION[‘seed’];
if (empty($seed)) {
$seed = rand();
$_SESSION[‘seed’] = $seed;
}
$orderby_statement = ‘RAND(‘.$seed.’)’;
}
return $orderby_statement;
}
How can I get it to work with this plugin?
Thanks
Hi Rena
This appears to be a duplicate of this thread:
https://support.searchandfilter.com/forums/search/search_filter_update_post_cache/
Ross has been away and is slowly working his way through outstanding threads. Please give him a few days to get back to you.