Display no results found and no more results with infinite scroll

Forums › Forums › Search & Filter Pro › Display no results found and no more results with infinite scroll

Viewing 2 posts – 1 through 2 (of 2 total)
  • Anonymous
    #273429

    Hi,

    My search form with infinite scroll works perfectly except i can’t get the No Results Found and End of Results at the end of my loop. I am displaying the results in a custom archive template on the same page as my search form. I tried a bunch of code found here in the forum but i just can’t get it to show…

    Any help would be appreciated

    here’s the end of my loop ($wp_query) in my custom archive template with my latest non working attempt!

    </div><!– END list-video-holder END OF ITEM LOOP –>

    <?php endwhile; ?>

    <?php else : ?>

    <div class=’search-filter-results-list’ data-search-filter-action=’infinite-scroll-end’>
    <span>End of Results</span>
    </div>

    <div class=’search-filter-results-list’ data-search-filter-action=’infinite-scroll-end’>
    <span>No Results Found</span>
    </div>

    <?php endif; wp_reset_postdata(); ?>
    </div><!– END list-inner-row-holder –>
    </div><!– END list-row-holder –>
    </main><!– #main –>
    </div><!– END Wrapper –>
    <?php get_footer(); ?>

    Trevor
    #273443

    This is a modified simple PHP template that might do as you wish:

    if ( ! defined( 'ABSPATH' ) ) {
    	exit;
    }
    
    if ( $query->have_posts() ) {
     ?>
     
     Found <?php echo $query->found_posts; ?> Results<br />
     <div class='search-filter-results-list'>
     <?php
      while ($query->have_posts())
      {
       $query->the_post();
       
       ?>
       <div class='search-filter-result-item'>
        <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
        
        <p><br /><?php the_excerpt(); ?></p>
        <?php 
         if ( has_post_thumbnail() ) {
          echo '<p>';
          the_post_thumbnail("small");
          echo '</p>';
         }
        ?>
        <p><?php the_category(); ?></p>
        <p><?php the_tags(); ?></p>
        <p><small><?php the_date(); ?></small></p>
        
        <hr />
       </div>
       
       <?php
      }
     ?>
     </div>
    <?php
    } else {
     
     //figure out which type of "no results" message to show
     $message = "noresults"; 
     if(isset($query->query['paged'])) {  
      if($query->query['paged']>1){
       $message = "endofresults";
      }
     }
     
        if($message=="noresults") {
        ?>
     <div class='search-filter-results-list' data-search-filter-action='infinite-scroll-end'>
      <span>No Results Found</span>
     </div>
     <?php
        } else {
     ?>
     <div class='search-filter-results-list' data-search-filter-action='infinite-scroll-end'>
      <span>End of Results</span>
     </div>
     <?php
     }
    }
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.