Support Forums

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro results display

Viewing 8 posts - 1 through 8 (of 8 total)
  • Peter Reid
    #202104

    Hello how do I prevent results showing before the submit or search is clicked?
    On the site i am working on, for instance, I would prefer the search form to show on its own, without the different posts, before the search query is submitted – mtai.ie
    (Same problem on this page find a teacher)
    Also, how do I prevent the date of the posts showing in the results?
    Thank you.

    Trevor Moderator
    #202121

    If you are using our Shortcode Display Results method, then the results.php needs to be modified like this (where the ID number will need to be changed to match your form ID):

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

    If using other methods, and if you have access to the template PHP files, you could use similar code.

    Make sure any files you modify are in the child theme folder (if you copy our results.php file, it needs to be in a sub-folder of the child theme, called search-filter, not our plugin folder or a parent theme folder).

    Peter Reid
    #202123

    OK, so are we talking about the results.php file in the Templates folder, in the search-filter-pro folder?
    Do I call the new sub-folder search-filter or search-filter-pro?
    Is the ID number to replace you refer to in the above example the number here – get(36613)?
    Do I paste the entire results.php after the comment out line //?
    i.e. replace “your current results.php code here” with the complete results.php code?

    Also, how do I prevent the date of the post showing in the results?
    As far as I can see, I’ve turned off meta.

    Trevor Moderator
    #202128

    You appear to be using our Shortcode Display Results method. The guide to customising it is here:

    https://searchandfilter.com/documentation/search-results/using-a-shortcode/#customising-the-results

    As you have two different forms, you will need two results templates, once named:

    447.php

    and another named:

    571.php

    The documentation tells you to name the folder search-filter

    The ID in my example 36613 needs replacing with 447 and 571, depending on the file it is in.

    You remove that whole comment line, and replace it with the code for the results template for the relevant search form and results page.

    Your results template for that page must still have this in it:

    <p><small><?php the_date(); ?></small></p>

    It needs to be removed.

    Peter Reid
    #202130

    OK Trevor, thanks for that comprehensive reply!

    Peter Reid
    #202545

    Hello, I’ve tried what you suggested on this page https://mtai.ie/how-to-find-a-course/ The search box displays on its own, which is what I want, but it is now not returning any results. Have I left something out, or gotten something wrong? I’ve tried turning off auto auto-submit. Also, when I try to refresh that page after doing a search, I get the “Confirm form resubmission” warning. I am using the shortcode method, and Elementor Pro for the templates.
    What I want to achieve is to display the search box, on its own, then the user clicks submit, and the results display.
    If it is not possible, how can I style the results so that they are more compact?
    Another issue I notice is that it is necessary to click the submit button more than once to get the form to submit.

    Trevor Moderator
    #202558
    This reply has been marked as private.
    Trevor Moderator
    #202607
    This reply has been marked as private.
Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.