Forums Forums Search & Filter Pro Initial Results

Viewing 3 posts - 1 through 3 (of 3 total)
  • Anonymous
    #103879

    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!

    Trevor
    #103891

    I am not sure, I would have to refer it to the developer, Ross.

    Ross Moderator
    #104170

    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

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