Ah, I see, you would have to edit the archive template and add code LIKE this, but you need to know the name of the wp_query array variable, which might not be $query (it varies from theme to theme, many use $wp_query instead):
<div>Found <?php echo $query->found_posts; ?> Results<br />
Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?></div>
That issue is simply the way that whatever code outputs the posts handles a ‘No Results Found’ scenario. As you are using our Shortcode method, and thus the infinite scroll version of results.php, this customized version handles ‘No Results’ better I think:
<?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
}
}
?>
Try using that instead?
You have chosen to use for now our Shortcode display results method, which means that the style of the display is somewhat basic, but can be customized by yourself:
https://searchandfilter.com/documentation/search-results/using-a-shortcode/#customising-the-results
It depends what content you want (what taxonomies, images, description, custom fields) and layout you want, as that will determine how easy it will be to do.
#1 This code:
Found <?php echo $query->found_posts; ?> Results<br />
Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />
Would become this:
<div style="text-align: right">Found <?php echo $query->found_posts; ?> Results, Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?></div>
#2 The above code would then become:
<div style="text-align: right">
<?php global $searchandfilter;
$sf_current_query = $searchandfilter->get(13622)->current_query();
if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { } else { ?>
Found <?php echo $query->found_posts; ?> Results,
<?php } ?>
Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?></div>
#3 This space?
https://www.screencast.com/t/GuYOFQ3qtQ3l
There appears to be blank lines in your content:
https://www.screencast.com/t/SivDBdT69fK
#4 This would require our filter to use (or be able to use) transients, which it cannot at present. I believe this will be added when we release V3, towards the end of June/early July.
Even then, you would probably require the services of a coder to hook it all up.
I checked back on my notes and before, with Thrive, I ‘cheated’ by creating a custom results.php template that mimicked the Thrive page. So, make the page and content as you like ignoring our plugin entirely, then inspect the HTML of the content area and edit the results.php we provide as an exemplar following this guide, so that it matches the structure and classes etc.):
https://searchandfilter.com/documentation/search-results/using-a-shortcode/#customising-the-results
So, here is one I made before:
<?php
/**
* Search & Filter Pro
*
* Sample Thrive Results Template
*
*/
if ( $query->have_posts() )
{
?>
Found <?php echo $query->found_posts; ?> Cars<br />
Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />
<div class="pagination">
<div class="nav-previous"><?php next_posts_link( 'Older posts', $query->max_num_pages ); ?></div>
<div class="nav-next"><?php previous_posts_link( 'Newer posts' ); ?></div>
<?php
/* example code for using the wp_pagenavi plugin */
if (function_exists('wp_pagenavi'))
{
echo "<br />";
wp_pagenavi( array( 'query' => $query ) );
}
?>
</div>
<div class="thrv_wrapper thrv_post_grid" data-unit="px">
<div class="tve_post_grid_wrapper tve_clearfix tve_post_grid_grid">
<div style="display: flex;" class="tve_pg_row tve_clearfix">
<?php
$thrive_counter = 0;
$thrive_row_counter = 0;
while ($query->have_posts())
{
if ( $thrive_counter == 0 ) && ( $thrive_row_counter > 0 ) {
?>
</div>
<div style="display: flex;" class="tve_pg_row tve_clearfix">
<?php
}
$query->the_post();
?>
<div class="tve_post tve_post_width_5 " style="align-items: stretch;">
<div class="tve_pg_container">
<?php
if ( has_post_thumbnail() ) {
$thrive_image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'single-post-thumbnail' );
?>
<a href="<?php the_permalink(); ?>">
<div class="tve_post_grid_image_wrapper" style="background-image: url('<?php echo $thrive_image[0]; ?>')">
<div class="tve_pg_img_overlay">
<span class="thrv-icon thrv-icon-forward"></span>
</div>
</div>
</a>
<?php
}
?>
<span class="tve-post-grid-title " style="font-size: 18px;line-height: 20px;font-family:'Arial', 'Helvetica', 'sans-serif';">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</span>
<div class="tve_pg_more" data-tve-custom-colour="62938813">
<a href="<?php the_permalink(); ?>">View Now</a>
<span class="thrv-icon thrv-icon-uniE602"></span>
</div>
</div>
</div>
<?php
$thrive_counter++;
if ( $thrive_counter > 4 ) {
$thrive_counter = 0;
$thrive_row_counter++;
}
}
?>
</div>
</div>
</div>
Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />
<div class="pagination">
<div class="nav-previous"><?php next_posts_link( 'Older posts', $query->max_num_pages ); ?></div>
<div class="nav-next"><?php previous_posts_link( 'Newer posts' ); ?></div>
<?php
/* example code for using the wp_pagenavi plugin */
if (function_exists('wp_pagenavi'))
{
echo "<br />";
wp_pagenavi( array( 'query' => $query ) );
}
?>
</div>
<?php
}
else
{
echo "No Results Found";
}
?>
AnonymousInactive
Hi there,
I’m trying to show number of results on term page but it’s always displaying plural version instead of one (I have only one service to show).
`<?php
$results = $wp_query->found_posts;
if (0 === $results) {
echo ‘<h1 class=”text-secondary mt-4 m-0 mt-sm-0″>’ . __(‘No service’, ‘textdomain’) . ‘</h1><span class=”lead”>’ . __(‘match your search criteria’, ‘textdomain’) . ‘</span>’;
}
elseif (1 === $results) {
echo ‘<h1 class=”text-secondary mt-4 m-0 mt-sm-0″>’ . $wp_query->found_posts . __(‘ service’, ‘textdomain’) . ‘</h1><span class=”lead”>’ . __(‘match your search criteria’, ‘textdomain’) . ‘</span>’;
} else {
echo ‘<h1 class=”text-secondary mt-4 m-0 mt-sm-0″>’ . $wp_query->found_posts . __(‘ services’, ‘textdomain’) . ‘</h1><span class=”lead”>’ . __(‘match your search criteria’, ‘textdomain’) . ‘</span>’;
}
?>’
Comparing the two forms is not easy, as you have dropdown selects in one and checkboxes in the other?
I DO see an issue with the infinite scroll that needs fixing, where it shows No Results at the bottom. This is a modified version of the standard infinite scroll results.php file to stop it from happening:
<?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
}
}
?>
As for the styling, might you be able to show me an annotated (naming colors, font family, weight, size) screenshot of the frontend form and what needs changing? You would need to upload the screenshot image to a file sharing site (like the WordPress Cloudup site) and share the link for it with me?
AnonymousInactive
Hi,
I’ve installed the plugin in a new site and the customer tells me that she’ve found contents in English.
I’ve tried to translated this strings but it is not possible because they are not translatable strings, so they are not included in search-filter.pot even if I udpdate search-filter.pot.
The reason is that these strings aren’t done like this: __( ‘My string’, $this->plugin_slug ),
For instance: /search-filter-pro/templates/results-infinite-scroll.php
<div class='search-filter-results-list' data-search-filter-action='infinite-scroll-end'>
<span>End of Results</span>
</div>
/search-filter-pro/templates/results.php
Found <?php echo $query->found_posts; ?> Results<br />
Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />
and
Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />
and
echo "No Results Found";
I was going to fix it but I’ve realized that if I do it, as soon as a new version were released all my work would be lost.
Would you mind fix it ?
If you update search-filter.pot I can help and send you the Spanish translation in order to be included in next releases.
Many thanks in advance.
You need to modify the code in the results.php to 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 this file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
global $searchandfilter;
$sf_current_query = $searchandfilter->get(70)->current_query();
if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) {
echo '<div>Nothing to see here folks!</div>';
} else {
if ( $query->have_posts() )
{
?>
Found <?php echo $query->found_posts; ?> Results<br />
Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />
<div class="pagination">
<div class="nav-previous"><?php next_posts_link( 'Older posts', $query->max_num_pages ); ?></div>
<div class="nav-next"><?php previous_posts_link( 'Newer posts' ); ?></div>
<?php
/* example code for using the wp_pagenavi plugin */
if (function_exists('wp_pagenavi'))
{
echo "<br />";
wp_pagenavi( array( 'query' => $query ) );
}
?>
</div>
<?php
while ($query->have_posts())
{
$query->the_post();
?>
<div>
<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>
</div>
<hr />
<?php
}
?>
Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />
<div class="pagination">
<div class="nav-previous"><?php next_posts_link( 'Older posts', $query->max_num_pages ); ?></div>
<div class="nav-next"><?php previous_posts_link( 'Newer posts' ); ?></div>
<?php
/* example code for using the wp_pagenavi plugin */
if (function_exists('wp_pagenavi'))
{
echo "<br />";
wp_pagenavi( array( 'query' => $query ) );
}
?>
</div>
<?php
}
else
{
echo "No Results Found";
}
}
?>
I think your theme uses a different array name, try this:
Found <?php echo $wp_query->found_posts; ?> Results
AnonymousInactive
Hi,
Our search listing has at the top “Found 5 Events” but what we really want is “Found 5 of 21 Events” where 21 is the number of Events shown when no filters are set. The code we use is:
Found <?php echo esc_html( $query->found_posts ); ?> Events
Is there an easy way for us to find the total Events on the list when no filters are set? The only way I can think of doing this is by writing a select count(*)... call directly to the DB that mimics the same query.
Thanks,
Chris