Got the files. I will post the results.php here for others to use if they wish, with their copy of Ignition and Thrive Visual Builder:
<?php
/**
* Search & Filter Pro
*
* Sample Thrive Results Template
*
* @package Search_Filter
* @author Trevor Nelmes
* @link http://www.designsandcode.com/
* @copyright 2016 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; ?> 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( 'Previous Page of Cars', $query->max_num_pages ); ?></div>
<div class="nav-next"><?php previous_posts_link( 'Next Page of Cars' ); ?></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; flex-wrap: wrap;" 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; flex-wrap: wrap;" 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( 'Previous Page of Cars', $query->max_num_pages ); ?></div>
<div class="nav-next"><?php previous_posts_link( 'Next Page of Cars' ); ?></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";
}
?>
Note that this search was for Cars for Sale, so some text strings have been modified to suit (like in the number of results and pagination).
AnonymousInactive
Hi Trevor,
thanks to your excellent guidance and explanations.
The results.php is working now as intended.
check out: https://www.kleinkunst.theater/
Pls note that I have translated some words into german.
(not yet internationalised code, but will add that as well)
<?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() )
{
?>
<?php echo $query->found_posts; ?> Beiträge gefunden<br />
Seite <?php echo $query->query['paged']; ?> von <?php echo $query->max_num_pages; ?><br />
<div class="pagination">
<div class="nav-previous"><?php next_posts_link( 'Ältere Beiträge', $query->max_num_pages ); ?></div>
<div class="nav-next"><?php previous_posts_link( 'Neuere Beiträge' ); ?></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="row row-masonry">
<?php
while ($query->have_posts())
{
$query->the_post();
?>
<article <?php post_class('post-masonry col-sm-' . $grid_col); ?>>
<div class="post-inner">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php echo at_post_thumbnail($post->ID, 'at_thumbnail', $args); ?>
</a>
<h2>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php the_title(); ?>
</a>
</h2>
<p><?php echo the_excerpt(); ?></p>
<div class="clearfix"></div>
</div>
</article>
<?php
}
?>
</div>
Seite <?php echo $query->query['paged']; ?> von <?php echo $query->max_num_pages; ?><br />
<div class="pagination">
<div class="nav-previous"><?php next_posts_link( 'Ältere Beiträge', $query->max_num_pages ); ?></div>
<div class="nav-next"><?php previous_posts_link( 'Neuere Beiträge' ); ?></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";
}
?>
So, it is relatively simple if you are using the Shortcode Display Results method. See the documentation:
http://www.designsandcode.com/documentation/search-filter-pro/search-results/using-a-shortcode/
See how it is using a template called results.php?
This is that file:
<?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 />
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";
}
?>
And here is it modified:
<?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() ) {
global $searchandfilter;
$sf_current_query = $searchandfilter->get(1526)->current_query();
if ($sf_current_query->is_filtered()) {
?>
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";
}
?>
replace 1526 with the id of your search form.
I think you would need to edit and remove lines 29 and 30 of this file:
results.php
in the templates folder. Depending on the display results method you are using (I am assuming you are using the shortcode method), you can copy that file to a sub-folder (you need to make this folder, if you don’t already have it, called search-filter
) of your theme folder. That way any plugin updates won’t break this change. The lines look like this:
Found <?php echo $query->found_posts; ?> Results<br />
Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />
See the documentation here (the Customising the Results section):
Using A Shortcode
I think what you want is
$wp_query->found_posts
It is part of any WordPress query, and tells you total found, not including pagination.
Thanks
Hi Klox
This is of course possible.
Which display method are you using?
With any query you can do:
echo $query->found_posts
Provided the name of the query is $query
thanks
AnonymousInactive
Hello Ross,
I have one example more detail.
global $wp_query;
$cat_obj = $wp_query->get_queried_object();
$catid=$cat_obj->term_id;
if ( $query->have_posts() )
{
$postfounds=$query->found_posts;
?>
<p> <?php echo sprintf(get_field(‘titulo_encontrados’,’product_cat_’.$catid),$postfounds); ?></p>
Then get_field(‘titulo_encontrados’,’product_cat_’.$catid) is empty when ajax is enabled.
Thanks for your time.
AnonymousInactive
Hey Ross:
I’m stuck in my attempt to create a custom search results page that displays only the title for the post(s) that are queried. I also want the “title” of the results page to state the number of results and the search query. Hoping you (or someone) can help?
I created a custom search.php file -> “searchpage.php”
I utilized the following code:
<?php if (have_posts()) : ?>
<h2 class="search-title">
<?php echo $wp_query->found_posts; ?> <?php _e( 'Search Results Found For Your Location' ); ?>: "<?php the_search_query(); ?>"
</h2>
<?php while (have_posts()) : the_post(); ?>
<div <?php post_class() ?>>
<h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
</div>
<?php endwhile; ?>
<?php else : ?>
<h2 class="center">No posts found. Try a different search?</h2>
<?php get_search_form(); ?>
<?php endif; ?>
** First – The results page title is not showing the query name – only the number of results.
Q: Do I need to use something other than “the_search_query” to display the title?
** Second – The results page is not showing the header, menu, or results navigation. It is a plain white page that displays only the title, and post titles (hyperlinked).
Q: Any idea what is missing so the normal layout displays?
Thanks
AnonymousInactive
Hey Ross
I uploaded that Dev version and it does fix my other problem or the search going all wonky due to plus signs, so thanks for that! However, it does not do anything for the random results order. I don’t have any pre-get-posts and the other sort orders work perfectly. The random one now just does it in order of date.
This is my current result.php, could you take a quick look to see if it would effect the random order?
if ( $query->have_posts() )
{
?>
<div class=”pagination”>
Found <?php echo $query->found_posts; ?> Results
<?php
/* example code for using the wp_pagenavi plugin */
if (function_exists(‘wp_pagenavi’))
{
echo “<br />”;
wp_pagenavi( array( ‘query’ => $query ) );
}
?>
</div>
<?php $i = 0; ?>
<?php
while ($query->have_posts())
{
$query->the_post();
?>
<?php
if($i == 0) {
echo ‘<div class=”ng-row”>’;
}
?>
<div class=”half_bbm”>
<div id=”myfirstid”>
<h3>“><?php the_title(); ?></h3>
“><?php
if ( has_post_thumbnail() ) {
echo ‘<p>’;
the_post_thumbnail(“small”);
echo ‘</p>’;
}
?>
<p><?php the_excerpt(); ?><br /><p>
</div>
</div>
<?php
$i++;
if($i == 3) {
$i = 0;
echo ‘</div>’;
}
?>
<?php
}
?>
<?php
if($i > 0) {
echo ‘</div>’;
}
?>
<div class=”pagination”>
<?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”;
}
?>
Thanks for you time. Also, I am liking the new version, especially the automatic retrieval of new custom fields! Two things I noticed. At first I got a weird Choose an Option title appearing underneath all of the titles for my filters but that went away after a few minutes which was weird. Also you may want to give a bit more information about what the secondary sort is because i have no idea what that would do. Anyway, nice work, and i really hope you can help me figure out this random sort thing because it is pretty important for my site.
Thanks again
Greg
AnonymousInactive
I’ve a results.php with
<?php
/**
* Search & Filter Pro
*
* Sample Results Template
*
* @package Search_Filter
* @author Ross Morsali
* @link http://www.designsandcode.com/
* @copyright 2014 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
*
* 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
*
*/
/* ROSS DEV CODE START */
//var_dump($query->posts);
/* $i = 1;
foreach($query->posts as $tpost)
{
echo $i." | ".$tpost->post_title;
echo "<br />";
$i++;
}
echo "<hr />";
$i = 1;
while ($query->have_posts())
{
$query->the_post();
echo $i." | ";
the_title();
echo "<br />";
$i++;
}
/* ROSS DEV CODE END */
if ( $query->have_posts() )
{
?>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="filter-results" >
<div class="filter-results-page"><?php echo $query->found_posts; ?> Ergebnisse Seite <?php echo $query->query['paged']; ?> von <?php echo $query->max_num_pages; ?></div>
<div class="filter-results-pagination">
<?php sf_pagination_prev_next($query->query['paged'], $query->max_num_pages); ?>
<?php sf_pagination_numbers($query->query['paged'], $query->max_num_pages, " "); ?>
</div>
</div>
</div>
</div>
<div class="row">
<?php
while ($query->have_posts())
{
$query->the_post();
$post_type = get_post_type( get_the_ID() );
?>
<?php
switch ($post_type) {
case 'wein':
echo '<div class="col-xs-12 col-sm-4 col-md-3 col-lg-3">';
echo '<div class="item-'.$post_type.'">';
$wine_id = get_the_ID();
$term_list = wp_get_post_terms($wine_id, 'winzer', array("fields" => "names"));
$title = get_the_title();
$permalink = get_permalink();
$stock = get_field('wine-stock');
$stock_text = get_field('wine-stock-text');
if (empty($stock_text)) {
$stock_text = "Ausverkauft!";
}
if (!empty($stock)) {
echo '<div class="wine-teaser"> <span></span><p>'.$stock_text.'</p></div>';
}
$name = get_field('wine-name');
$img_url = get_field('wine-detail-image');
if (empty($img_url)) {
$img_url = '/wordpress/wp-content/uploads/wine_empty.png';
}
$year = get_field('wine-detail-year');
$sf = get_field('wine-detail-soul-faktor');
$size = get_field('wine-detail-size');
echo '<div class="item-overlay"><div class="overlay-content">'.$sf.'<br>Flasche'.$size.'</div></div>';
echo '<a href="'.$permalink.'" title="'.$title.'">';
//echo '<img src="'.aq_resize( $img_url, '300').'" alt="'.$title.'"></a></div>';
echo '<img src="'.aq_resize( $img_url, '300').'" alt="'.$title.'"></a></div>';
echo '<div class="wine-description"><h2><a href="'.$permalink.'" title="'.$title.'">'.$year.' '.$name.'</a></h2>';
echo '<h3>'.$term_list[0].'</h3></div>';
break;
case 'winzer':
$grower_id = get_the_ID();
$term_list_country = wp_get_post_terms($grower_id, 'land', array("fields" => "names"));
$term_list_region = wp_get_post_terms($grower_id, 'anbaugebiet', array("fields" => "names"));
$img_url = get_field('winegrower-preview-image');
$logo_url = get_field('winegrower-logo');
$title = get_the_title();
$permalink = get_permalink();
$exclusive = get_field('winegrower-exclusive');
if ($exclusive == 1) {
$addexclusive = ' - Exklusiv bei Wein am Limit';
} else {
$addexclusive = '';
}
echo '<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">';
echo '<div class="item-'.$post_type.'">';
if (!empty($img_url)) {
if (!empty($logo_url)){
echo '<div class="logo-overlay"><img src="'.aq_resize( $logo_url, '100').'"></div>';}
echo '<a href="'.$permalink.'" title="'.$title.'">';
//echo '<img src="'.aq_resize( $img_url, '600', '290' , true).'" alt="'.$title.'"></a></div>';
echo '<img src="'.aq_resize( $img_url, '600', '290' , true).'" alt="'.$title.'"></a>';
}
echo '</div>';
echo '<div class="grower-description"><h2><a href="'.$permalink.'" title="'.$title.'">'.$title.$addexclusive.'</a></h2>';
echo '<h3>'.$term_list_region[0].', '.$term_list_country[0].'</h3></div>';
break;
}
?>
</div>
<?php
}
?>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="filter-results" >
<div class="filter-results-page"><?php echo $query->found_posts; ?> Ergebnisse Seite <?php echo $query->query['paged']; ?> von <?php echo $query->max_num_pages; ?></div>
<div class="filter-results-pagination">
<?php sf_pagination_prev_next($query->query['paged'], $query->max_num_pages); ?>
<?php sf_pagination_numbers($query->query['paged'], $query->max_num_pages, " "); ?>
</div>
</div>
</div>
</div>
<?php
}
else
{
echo '<div class="filter-results" style="height:38px;"><div class="filter-results-page"><div class="filter-results-pagination"></div></div></div>';
echo '<div style="width:100%; text-align:center;min-height:400px;padding-top:100px;">Keine Produkte gefunden.</div>';
}
?>
which is workin no more after update to S&F 2.0.3 (from 1.4.2) – I’ve rebuild all caches, the site stay just empty. Any ideas on this?
Best.