Forums › Forums › Search & Filter Pro › Display no results found and no more results with infinite scroll
- This topic has 1 reply, 2 voices, and was last updated 3 years, 10 months ago by Trevor.
-
Anonymous(Private) January 21, 2021 at 2:29 am #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(Private) January 21, 2021 at 6:13 am #273443This 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 } }
-
AuthorPosts