Post grid results display

Forums › Forums › Search & Filter Pro › Post grid results display

Tagged: ,

Viewing 2 posts – 1 through 2 (of 2 total)
  • Anonymous
    #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
    #260128

    If 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.

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