Forums Forums Search & Filter Pro Hide posts if nothing found

Viewing 10 posts - 1 through 10 (of 31 total)
  • Anonymous
    #169015

    Hello,
    Thank you for great plugin!
    Can you help me, please?
    I choose custom display method with wp_query and choose the same result page. If I have no results by choosing filters or using search, all posts are visible. How can I hide them?
    Thanks

    Trevor
    #169025

    Do you mean that if the user does not use the filters or search, then you want no results? You would need to edit your template file to add some logic in. Like this:

    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 here
    }

    Change 1024 to the ID number of your form (from the form shortcode).

    Anonymous
    #169102

    No, I mean, for example, if user searches word, which not in any post or filter by term, which not associated with any post, i want to hide results

    Trevor
    #169147

    With that display method, your theme template controls what is displayed when no results are found.

    Are you able to upload that template file to a file sharing site so that I can see it?

    Anonymous
    #169158
    Trevor
    #169162

    On line 106 I see and if starting, and also on the same line I see a while starting. The while ends on line 172, but where does the if end?

    Anonymous
    #169164

    On line 172, after endwhile; and wp_reset_postdata();

    Trevor
    #169167

    Ah, I see, yes.

    So, what happens if you replace that line with this:

    <?php endwhile; ?>
    <div><p>No results found</p></div>
    <?php>wp_reset_postdata(); endif; ?>
    Anonymous
    #169173

    I already have tried this, the same problem

    Trevor
    #169175

    Do you see the message when results are not found? If not, then your theme is doing something odd.

Viewing 10 posts - 1 through 10 (of 31 total)