Forums Forums Search & Filter Pro Hide all results before a search query is made

Tagged: 

Viewing 8 posts - 1 through 8 (of 8 total)
  • Anonymous
    #181943

    Hi Trevor,

    I hope you’ve been keeping well. I’m trying to implement your plugin on another site. This time I need to do a simple search. I’m using the custom method and with action=”filter_next_query”.

    I want to hide the search results before a query is made. I followed your previous method and modified the results.php but that works only for shortcode method. Can we do the same for custom method?

    Trevor
    #181946

    The Custom method relies on a theme template of some sort. Are you using a theme php template, as the logic would look something like this to do as you want:

    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 {
      // the theme template PHP code here
    }

    Change the number 1024 with your form’s ID number (from the shortcode).

    This code will likely need to be used within a part the template file that actually outputs the results (around the if query … have … posts bit).

    Anonymous
    #181948
    This reply has been marked as private.
    Trevor
    #181961

    I am sorry, but if you are using a Page Builder, there isn’t a way I know to do what you want.

    Anonymous
    #182010
    This reply has been marked as private.
    Trevor
    #182014

    You would need to be using our Shortcode Display results method, 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(1024)->current_query();
    if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) {
      echo '<div>Nothing to see here folks!</div>'; 
    } else {
      // the results.php PHP code here
    }

    Make sure you change the ID number in that snippet to the ID number of your form.

    Anonymous
    #182020

    Yes Trevor, I have copied the file. But I have no idea how to start customizing the CSS on the results page since there are no element IDs from what I could see. How can I go about coding for this? Do you have any sample code for results.php that I could start with?

    Trevor
    #182022

    No samples no. I have published some on this forum, but the IDs and Classes are very much theme specific.

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