Only Show Results Once Submitted

Forums Forums Search & Filter Pro Only Show Results Once Submitted

Viewing 4 posts – 1 through 4 (of 4 total)
  • Anonymous
    #234004

    I am using the shortcode for search and results on the same page.

    This all works fine. However as default the results shortcode shows all results possible before a search is made.

    Is there a way to set it, that when you go to this page, it only shows the search bar, and then when a search is made, it shows the results, instead of showing all results as default?

    Thanks Mike

    Trevor
    #234043

    You would need to be using our Shortcode Display results method (as you are), and have followed the ‘guide to customising’:

    https://support.searchandfilter.com/documentation/search-filter-pro/search-results/using-a-shortcode/

    Once you have a copy of the results.php file in a search-filter sub-folder of your theme, you can edit that file, like this (leave the PHP comments at the top outside and before this code):

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(1605)->current_query();
    if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) {
      echo '<div>Nothing to see here folks!</div>'; 
    } else {
      // the current resuts.php code here
    }
    Anonymous
    #234072

    Thanks, that worked perfectly.

    Trevor
    #234076

    Thanks for letting me know. I will close this thread for now.

Viewing 4 posts – 1 through 4 (of 4 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.