Forums › Forums › Search & Filter Pro › Infinite Scroll
- This topic has 9 replies, 2 voices, and was last updated 4 years, 11 months ago by Trevor.
-
Anonymous(Private) November 12, 2019 at 11:53 am #226356
Hi Support,
I seem to be having an issue with the infinite scroll on the results, it works perfectly for the most part and as expected, however if I have a result with no posts in I get a duplicate ‘End of Results’ message on the page, the first one appears almost immediately and then the second appears after the infinite scroll GIF kicks in and realises that notthing has been found.
Is there a work around for this or a way of stopping it from happening, it’s not a major issue just looks a bit messy on page.
Thank you
ScottTrevor(Private) November 12, 2019 at 5:41 pm #226404Are you using our shortcode display results method?
If so, this is a modified exemplar results.php file to account for this behavior:
<?php /** * Search & Filter Pro * * Sample Results Template * * @package Search_Filter * @author Ross Morsali * @link http://www.designsandcode.com/ * @copyright 2015 Designs & Code * * Note: these templates are not full page templates, rather * just an encaspulation of the your results loop which should * be inserted in to other pages by using a shortcode - think * of it as a template part * * This template is an absolute base example showing you what * you can do, for more customisation see the WordPress docs * and using template tags - * * http://codex.wordpress.org/Template_Tags * */ 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 } } ?>
Anonymous(Private) November 18, 2019 at 4:34 pm #226945Hi Trevor,
Apologies I’ve only just gotten around to trying this out, at the minute I get both messages coming up and I’m not entirely sure why, this is my results.php file.
<?php
/**
* Search & Filter Pro
*
* Sample Results Template
*
* @package Search_Filter
* @author Ross Morsali
* @link https://searchandfilter.com
* @copyright 2018 Search & Filter
*
* Note: these templates are not full page templates, rather
* just an encaspulation of the your results loop which should
* be inserted in to other pages by using a shortcode – think
* of it as a template part
*
* This template is an absolute base example showing you what
* you can do, for more customisation see the WordPress docs
* and using template tags –
*
* http://codex.wordpress.org/Template_Tags
*
*/if ( $query->have_posts() )
{
?>
<div class=”flex-grid” data-aos=”fade-up”>
<?php
while ($query->have_posts()){
$query->the_post();
?>
<div class=”RoleGridWrapper col”>
<?php if( get_field(‘scrub_colour’) == ‘navy-blue’){ $postcolor = ‘#153F74’; } ?>
<?php if( get_field(‘scrub_colour’) == ‘cornflower-blue’){ $postcolor = ‘#5184C4’; } ?>
<?php if( get_field(‘scrub_colour’) == ‘mediterranean-blue’){ $postcolor = ‘#009EC7’; } ?>
<?php if( get_field(‘scrub_colour’) == ‘ocean-blue’){ $postcolor = ‘#64BFD4’; } ?>
<?php if( get_field(‘scrub_colour’) == ‘pale-sky-blue’){ $postcolor = ‘#97BADE’; } ?>
<?php if( get_field(‘scrub_colour’) == ‘dark-green’){ $postcolor = ‘#00A296’; } ?>
<?php if( get_field(‘scrub_colour’) == ‘mid-green’){ $postcolor = ‘#92CEBD’; } ?>
<?php if( get_field(‘scrub_colour’) == ‘silver-grey’){ $postcolor = ‘#ABAAAB’; } ?>
<div class=”roleContWrapper” style=”border-top: solid 10px <?php echo $postcolor; ?>”>
<div class=”cardTAB”>
<svg id=”scrubsIcon” data-name=”Layer 1″ xmlns=”http://www.w3.org/2000/svg” viewBox=”0 0 40 40″><title>Scrubs Icon</title><path style=”fill:<?php echo $postcolor; ?>;” d=”M39.6,7.22a40.13,40.13,0,0,0-13-4.12,1.11,1.11,0,0,0-1.39.72c-.43.91-.88,1.73-.92,1.8-1.72,3.28-3.54,6-4.18,6.19-.66-.16-2.48-2.63-4.25-5.63-.46-.76-.8-1.42-1.25-2.28a1.29,1.29,0,0,0-1.52-.77A37.94,37.94,0,0,0,.4,7.22a.78.78,0,0,0-.32,1L3.47,15a.79.79,0,0,0,.9.41l3.49-.87L6.78,36.11a.79.79,0,0,0,.79.83H32.43a.79.79,0,0,0,.79-.83L32.14,14.57l3.49.87a.79.79,0,0,0,.9-.41l3.39-6.78A.78.78,0,0,0,39.6,7.22Z”/></svg>
</div>
“>
<h3 class=”postHeader”><?php the_title(); ?></h3>
<div class=”postCATS”>
<?php
$categories = get_the_category();
$parentCatName = get_cat_name($categories[0]->parent);
if ( ! empty( $categories ) ) {
?>
<span class=”parentCAT”><?php echo esc_html( $parentCatName ); ?></span>
<?php
}
?>
</div>
<p class=”postIntro”><?php the_field(‘brief_role_description’); ?></p>
<div class=”readmoreWrapper”>
<p class=”postreadmore” href=”<?php the_permalink(); ?>”>Learn more</p>
</div>
</div>
</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
}
}
?>Can’t seem to see why it’s not choosing one or the other, the only way at the moment I can get it to find no results is to search for something that I know isn’t available.
Thank you
ScottTrevor(Private) November 19, 2019 at 4:54 pm #227033As you have changed our code, and therefore the HTML structure and classes etc, you will need to add settings in the Infinite Scroll section.
Looking at the structure that you have, is this class (
flex-grid
):https://www.screencast.com/t/ijjByxnMbzTh
used elsewhere on the page?
If not, then the settings might be these:
Anonymous(Private) November 19, 2019 at 5:03 pm #227041Perfect tha worked a treat, I had to change .RoleGridWrapper to .col as the plugin seemed to have an issue with something in that particular class, it seemed to grumble about converting to lowercase, but changing to .col which is an additional class on the items anyway seems to have worked.
Thank you
-
AuthorPosts