Forums › Forums › Search & Filter Pro › Post grid results display
- This topic has 1 reply, 2 voices, and was last updated 4 years, 2 months ago by Trevor.
-
Anonymous(Private) September 21, 2020 at 6:48 am #260102
Hi!
I want to prevent the result appeared before clicking the button or selecting any search form field.
I’ve used this https://support.searchandfilter.com/forums/topic/results-display-3/, and it worked.However, when I try to use Post Grid plugin to customize the display, the result is always shown after page load (same as before using custom results.php).
How to fix that?Thank you
Trevor(Private) September 21, 2020 at 11:58 am #260128If you mean that you want to only show results if the form has been used, this is not possible using the Post Grid plugin, as it has no option to stop the results showing. I suppose you could be sneaky and place the Post Grid shortcode inside a PHP snippet shortcode, where you can then use PHP to detect if the filter has been used. That might work. You would need this plugin:
https://wordpress.org/plugins/post-snippets/
Then use that to create a shortcode that contains PHP, like this:
global $searchandfilter; $sf_current_query = $searchandfilter->get(1234)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { do_shortcode('[searchandfilter id="1234" action="filter_next_query"]'); do_shortcode('[post_grid id="5678"]'); }
Replace the ID numbers to suit.
Then place the shortcode for that snippet in the page instead of the two you have inside it. That might work. For Ajax to work, I think you might need to place the shortcode from the snippet plugin inside a div with its own class name, and use that for the Ajax Container.
-
AuthorPosts