Support Forums

The forums are closed and will be removed when we launch our new site.

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

Forums Forums Search & Filter Pro Post grid results display

Tagged: ,

Viewing 2 posts - 1 through 2 (of 2 total)
  • Rama Wardhana
    #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 Moderator
    #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)

The forum ‘Search & Filter Pro’ is closed to new topics and replies.