Forums › Forums › Search & Filter Pro › Stop Infinite Scroll If Only One Page or Results
Tagged: infinite scroll
- This topic has 8 replies, 2 voices, and was last updated 7 years, 4 months ago by Anonymous.
Viewing 9 posts - 1 through 9 (of 9 total)
-
Anonymous(Private) July 25, 2017 at 4:10 pm #122625
I can’t show you the page but this is the code
<?php if ( $query->have_posts() ) { echo '<div class="posts-wrapper">'; while ($query->have_posts()) { $query->the_post(); get_template_part('templates/content', get_post_type() != 'post' ? get_post_type() : get_post_format()); } echo '</div>'; ?> <nav class="pagination" style="display: none;"> <ul> <li class="previous"><?php next_posts_link( 'Older posts', $query->max_num_pages ); ?></li> <li><span>Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?> (<?php echo $query->found_posts; ?> results)</span></li> <li class="next"><?php previous_posts_link( 'Newer posts' ); ?></li> </ul> </nav> <?php } else { echo '<p class="no-results">Sorry, we couldn\'t find any results to match your search. Please try broadening your search, or <a href="' . home_url() . '" title="Return to the homepage">returning to the homepage</a>.</p>'; } ?>
Anonymous(Private) July 25, 2017 at 4:55 pm #122644OK. I’ve not built our customisation but I can see now from your template that we’re not outputting the right message when there are no results and maybe we need to data attributes as well?
<div class='search-filter-results-list' data-search-filter-action='infinite-scroll-end'>
Anonymous(Private) July 26, 2017 at 9:16 am #122816I have restored the default code and message ‘End of results’ and this seems to work OK now. The AJAX still loads and query runs to try and find more results so it isn’t disabled if only one page of results are found from the initial query, but the message makes sense now.
-
AuthorPosts
Viewing 9 posts - 1 through 9 (of 9 total)