Hide Results until Search is Submitted

Forums › Forums › Search & Filter Pro › Hide Results until Search is Submitted

Viewing 3 posts – 1 through 3 (of 3 total)
  • Anonymous
    #190148

    I’m using the shortcode method with Ajax and a submit button and tried following this method to hide results until a search is submitted. The search results are hidden but then nothing shows when I submit the search. Do you know what could be wrong? I added the code to my custom results template.

    https://support.searchandfilter.com/forums/topic/force-selection/#post-87657

    Anonymous
    #190149

    I tried setting the opacity of .search-filter-results to 0 and that seems to do the trick since an opacity of 1 is added inline once a search is completed. I would have liked to get the template code working but this solution will do.

    Trevor
    #190171

    If you are using the Shortcode results method, and our results.php template file, it would look like this:

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(1024)->current_query();
    if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) {
      echo '<div>Nothing to see here folks!</div>'; 
    } else {
      // your template archive code/loop OR results.php code here
    }

    Change 1024 to the ID number of your form (from the form shortcode).

Viewing 3 posts – 1 through 3 (of 3 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.