-
AuthorSearch Results
-
July 25, 2017 at 4:10 pm #122625
In reply to: Stop Infinite Scroll If Only One Page or Results
AnonymousInactiveI can’t show you the page but this is the code
<?php if ( $query->have_posts() ) { echo '<div class="posts-wrapper">'; while ($query->have_posts()) { $query->the_post(); get_template_part('templates/content', get_post_type() != 'post' ? get_post_type() : get_post_format()); } echo '</div>'; ?> <nav class="pagination" style="display: none;"> <ul> <li class="previous"><?php next_posts_link( 'Older posts', $query->max_num_pages ); ?></li> <li><span>Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?> (<?php echo $query->found_posts; ?> results)</span></li> <li class="next"><?php previous_posts_link( 'Newer posts' ); ?></li> </ul> </nav> <?php } else { echo '<p class="no-results">Sorry, we couldn\'t find any results to match your search. Please try broadening your search, or <a href="' . home_url() . '" title="Return to the homepage">returning to the homepage</a>.</p>'; } ?>July 1, 2017 at 10:32 am #118140In reply to: Visual Results?
TrevorParticipantBTW, this is the grid making results.php I used for your genesis theme:
<?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 $odd_check = 1; $first_check = 1; while ($query->have_posts()) { $query->the_post(); if ( $odd_check == 1 ) { $odd_class = " odd"; } else { $odd_class = ""; } if ( $first_check == 1 ) { $first_class = " first"; } else { $first_class = ""; } ?> <article class="simple-grid one-third<?php echo $odd_class;?><?php echo $first_class;?> post-<?php echo get_the_ID();?> post type-post status-publish format-standard entry"> <a href="<?php the_permalink(); ?>" class="alignnone"> <?php the_post_thumbnail("small");?> </a> <header class="entry-header"> <h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> </header> </article> <?php $odd_check++; if ( $odd_check == 3 ) $odd_check = 1; $first_check++; if ( $first_check == 4 ) $first_check = 1; } ?> <div style="clear: both;"> Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?> </div> <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"; } ?>June 15, 2017 at 11:19 am #115150In reply to: Customize posts given to archive loop
TrevorParticipantThis is where the post count comes from:
https://codex.wordpress.org/Plugin_API/Filter_Reference/found_posts
June 12, 2017 at 10:06 am #114400In reply to: No results, no message appears
AnonymousInactiveHi,
Here is the results.php, but I have another for costumization.RESULTS.PHP
<?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 style="display: inline-block; width:50%;"> <?php if ( has_post_thumbnail() ) { echo '<p>'; the_post_thumbnail("small"); echo '</p>'; } ?> </div> <div style="display: inline-block; width:50%;"> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <p> <?php the_category(); ?> </p> <p> <?php the_tags(); ?> </p> <p> <small> <?php the_date(); ?> </small> </p> <p><br/> <?php the_excerpt(); ?> </p> </div> < /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"; } ?>2553.PHP
<?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() ) { ?> <div style="float: left;"> <strong> <?php echo $query->found_posts; ?> </strong> resultado(s)</div> <div style="float: right;">Pág. <?php echo $query->query['paged']; ?> de <?php echo $query->max_num_pages; ?> </div> <div style="clear: both;"></div> <hr> <div class="pagination" style="width: 100% !important;"> <div style="float: right;"> <?php next_posts_link( '<span class="ion-arrow-right-c"></span>', $query->max_num_pages ); ?> </div> <div style="float: left;"> <?php previous_posts_link( '<span class="ion-arrow-left-c"></span>' ); ?> </div> <div style="clear: both;"></div> <?php /* example code for using the wp_pagenavi plugin */ if ( function_exists( 'wp_pagenavi' ) ) { echo "<br />"; wp_pagenavi( array( 'query' => $query ) ); } ?> </div> <div style="clear: both;"></div> < ? php while ( $query->have_posts() ) { $query->the_post(); ?> <div style="float: left; width: 50%; padding-bottom: 50px;"> <?php if ( has_post_thumbnail() ) { echo '<p>'; the_post_thumbnail("small"); echo '</p>'; } ?> </div> <div style="float: left; width: 50%; padding-left: 20px; padding-bottom: 50px;"> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> <p> <?php echo do_shortcode('[pods field="resumo_objectivos"]'); ?> </p> <p> <?php echo do_shortcode('[pods field="datas"]'); ?> </p> <p> <?php echo do_shortcode('[pods field="preco"]'); ?> </p> <p> <?php echo do_shortcode('[pods field="duracao"]'); ?> </p> </div> <hr/> <div style="clear: both;"></div> < ? php } ?> <div class="pagination" style="width: 100% !important;"> <div style="float: right;"> <?php next_posts_link( '<span class="ion-arrow-right-c"></span>', $query->max_num_pages ); ?> </div> <div style="float: left;"> <?php previous_posts_link( '<span class="ion-arrow-left-c"></span>' ); ?> </div> <div style="clear: both;"></div> <?php /* example code for using the wp_pagenavi plugin */ if ( function_exists( 'wp_pagenavi' ) ) { echo "<br />"; wp_pagenavi( array( 'query' => $query ) ); } ?> </div> <div style="clear: both;"></div> < ? php } else { echo "Não foram encontrados resultados"; } ?>May 15, 2017 at 11:39 am #108801In reply to: Number of results not showing on "Archive"
RossKeymasterHi Tom
Archive display method uses the global $wp_query object, rather than the local $query.
So it should be:
Found <?php global $wp_query; echo $wp_query->found_posts; ?> Results<br />Thanks
May 15, 2017 at 11:18 am #108800Topic: Number of results not showing on "Archive"
in forum Search & Filter Pro
AnonymousInactiveHi Trevor, I hope you have had a nice weekend.
Since setting up my code in an “archive” it is working great although when I try to display the number of results with the code from results.php it doesn’t work. I am trying the following code:
Found <?php echo $query->found_posts; ?> Results<br />Which I copied from results.php
I’m sure it has something to do with “$query” but I have no idea what to replace it with?
Any ideas on this one?
May 12, 2017 at 5:02 pm #108556In reply to: Total Number of Results
TrevorParticipantCan you use the
post_countvariable instead offound_posts?May 12, 2017 at 4:30 pm #108541Topic: Total Number of Results
in forum Search & Filter Pro
AnonymousInactiveIn the post template, the code
<?php echo $query->found_posts; ?>gives the dynamic number of filtered results. However, I would like to get the static total number of posts irrespective of what filters are used. How could I do this?
many thanks!
May 2, 2017 at 2:02 pm #105908Topic: Number of resluts and terms of search
in forum Search & Filter Pro
AnonymousInactiveHello, firs of all: great plugin! Thank you.
Problems:
1. need to show number of total results. Is it working; <?php echo $sf_query->found_posts; ?> ?
2. Is it possible display terms of search?
Thank youApril 27, 2017 at 2:08 pm #105232In reply to: Results count… can't make it work
TrevorParticipantHi. You have ‘Use Background Processes’ disabled in the plugin settings. This will mean that the results may be wrong unless you keep up to date with rebuilding the cache.
So, to the code. This code is wrong:
$total_results = $query->found_posts;It must be:
$total_results = $wp_query->found_posts;I have edited it for you.
-
AuthorSearch Results
Search Results for 'found_posts'
-
Search Results
-
Hi Trevor, I hope you have had a nice weekend.
Since setting up my code in an “archive” it is working great although when I try to display the number of results with the code from results.php it doesn’t work. I am trying the following code:
Found <?php echo $query->found_posts; ?> Results<br />Which I copied from results.php
I’m sure it has something to do with “$query” but I have no idea what to replace it with?
Any ideas on this one?
Topic: Total Number of Results
In the post template, the code
<?php echo $query->found_posts; ?>gives the dynamic number of filtered results. However, I would like to get the static total number of posts irrespective of what filters are used. How could I do this?
many thanks!
Hello, firs of all: great plugin! Thank you.
Problems:
1. need to show number of total results. Is it working; <?php echo $sf_query->found_posts; ?> ?
2. Is it possible display terms of search?
Thank you