- This topic has 2 replies, 3 voices, and was last updated 9 years, 2 months ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 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 › Initial Results
Hey!
So the post “Customize initial results” was really helpful, however is it possible to display a random list of results where “// your holding template code here” is at?
global $searchandfilter;
$sf_current_query = $searchandfilter->get(1234)->current_query();
if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) {
// your holding template code here
} else {
// your normal template code here
}
Thanks!
Hi Nicholas
In S&F settings, you can goto the posts tab and change your sort order to random.
Just to let you know though, this may not be the random effect you want – currently, WP supports random ordering of a query / results, but, every page refresh, the randomisation happens again (so you will always lose your position if using pagination).
Alternatively, in your template, you could add the results to an array, shuffle them, and then loop through the array, which will in effect have a similar effect to above – you will have each page of results randomised (preventing the refresh issue descirbed above).
Hope that helps.
Best