Forums › Forums › Search & Filter Pro › Customizing what displays before any search has been performed
- This topic has 6 replies, 2 voices, and was last updated 7 years, 7 months ago by
Trevor.
-
Trevor(Private) May 7, 2018 at 11:22 am #176099
It does indeed make sense. Here is how you would code what you want to do:
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).
Anonymous(Private) May 7, 2018 at 6:14 pm #176170Thank you, Trevor! This code works well to show different text on a “blank” form.
Did you have any thoughts about the first half of my question? Is there a way for the S&F Pro results to include all items to start, rather than none? Right now my form is functioning in an un-intuitive way — in addition to showing nothing at the start, it also shows nothing for any combination of items unless a search term or a taxonomy has been chosen. For instance, if you leave the search field blank and have “All topics” chosen, and choose an author from the dropdown, it says no results (even though there are posts by that author). Or if I choose a post type, and leave it on “All authors,” and click submit, I still get no results.
Is this something particular to my site, or is it the way the plugin functionality is supposed to work? Fundamentally, I would like if the results defaulted to show every possible result, so if I chose an author and clicked “submit” I got all posts by that author that meet the other criteria of the form.
-
AuthorPosts