Forums › Forums › Search & Filter Pro › If you set infinite scroll "end message" it'll be the same for No Result.
- This topic has 2 replies, 2 voices, and was last updated 6 years, 11 months ago by Anonymous.
-
Anonymous(Private) December 15, 2017 at 11:34 am #147794
Hi,
first of all let me say thank you for your great work and the amazing plugin you’ve built…
It really saved me a big amount of developing hours. 🙂But…I have got a question:
Basically I set up an ajax infinite scroll on my search result page…and everything is working fine.
Also I followed your instructions and had a look into the result-infinite-scroll.php in order to customize the final message when “all posts are loaded”. And it works.
However there’s an issue I couldn’t solve yet. And is the following:
If you set search parameters and the reaserch don’t come up with any result, the message that you will get…is exactly the same that I set for the “infinite scroll end” and it should be consider a mistake.Because in one case you loaded all posts, in the other case you don’t have any post that is matching your searching criterias.
I looked through this and consirered the value of $wp_query, exactly:
$wp_query->post_count
$wp_query->found_posts
$wp_query->current_post
But basically couldn’t find out a solution…. in the last “ajax call” ( when all post are loaded) it get back the same value you have in “no result case”, so you are not able to know wich case is.Is there any way to solve it, in order to get 2 different messages?
Thanks
MatteoTrevor(Private) December 15, 2017 at 11:57 am #147795Have a look at this:
<?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 } } ?>
-
AuthorPosts