Forums › Forums › Search & Filter Pro › Infinite scroll works – but just once
Tagged: infinite scroll, post type archive
- This topic has 7 replies, 2 voices, and was last updated 5 years, 11 months ago by Anonymous.
-
Anonymous(Private) November 28, 2018 at 2:00 am #194758
Hey!
I have a filter set up for a portfolio and want to use infinite scroll. I’ve followed your guidelines on setting up for both infinite scroll and post type archives, but I only get one set of additional posts. By this, I mean 12 posts are initially loaded, and when I scroll I get 12 more posts – but that’s it – no more posts as I continue to scroll. There should be 120+ posts.
Here is the archive template code:
<?php /** * The template for displaying portfolio archive pages. * * @package WPGood */ $intro = get_field('introductory_text', 4097); $archive_title = get_the_title(4097); get_header(); ?> <main id="main" class="content-area" role="main"> <?php if ( have_posts() ) : ?> <header class="page-header"> <h1 class="page-title"><?php echo $archive_title; ?></h1> <div class="gallery-intro"> <p><small>Updated <?php the_modified_date(); ?></small></p> <?php echo $intro; ?> </div> </header><!-- .page-header --> <div class="gallery-filter"> <?php echo do_shortcode('[searchandfilter slug="portfolio-filter"]'); ?> </div> <div class="gallery-posts"> <?php while ( have_posts() ) : the_post(); get_template_part( 'template-parts/content', 'gallery-summary' ); endwhile; ?> <span class="gallery-end" data-search-filter-action='infinite-scroll-end'>No more results</span> </div> <?php else : get_template_part( 'template-parts/content', 'none' ); endif; ?> </main><!-- #main .content-area --> <?php get_footer();
The template part for gallery summary is wrapped in an article tag, which I have set as the
Post / Result Selector.Hopefully I’m not missing something silly… any help would be most appreciated.
Thanks!
Trevor(Private) November 29, 2018 at 2:40 pm #194896I made a couple of minor changes, but to no avail. I think it is the structure of the PHP in your template. See here what our exemplar structure looks like:
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 { ?> <div class='search-filter-results-list' data-search-filter-action='infinite-scroll-end'> <span>End of Results</span> </div> <?php } ?>
Anonymous(Private) December 4, 2018 at 11:12 pm #195281We resolved this by updating:
<div class='search-filter-results-list' data-search-filter-action='infinite-scroll-end'> <span>End of Results</span> </div>
to:
<div class='search-filter-results-list'> <span>End of Results</span> </div>
This goes against documentation, but worked.
-
AuthorPosts