Forums › Forums › Search & Filter Pro › Results showing up twice
- This topic has 11 replies, 2 voices, and was last updated 4 years, 2 months ago by Trevor.
-
Anonymous(Private) September 21, 2020 at 1:57 pm #260157
Hi all,
I’ve updated the page to display results, however, the filter runs and pull the correct results – but these results are placed on top of the results that were there previously – is there a bit of code I’m missing for clearing the previous results?Anonymous(Private) September 21, 2020 at 1:59 pm #260158This is the code I’ve given in the results display
<?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 this file is called directly, abort.
if ( ! defined( ‘ABSPATH’ ) ) {
exit;
}if ( $query->have_posts() )
{while ($query->have_posts())
{
$query->the_post();?>
<div>
<?php get_template_part(‘template-parts/content’, get_post_type()); ?></div>
<!– <hr /> –>
<?php
}
?>
Page <?php echo $query->query[‘paged’]; ?> of <?php echo $query->max_num_pages; ?><br /><div class=”pagination”>
<?php
}
else
{
echo “No Results Found”;
}
?>Anonymous(Private) September 21, 2020 at 2:04 pm #260159I’ve updated so more in line with original
<?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 this file is called directly, abort.
if ( ! defined( ‘ABSPATH’ ) ) {
exit;
}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>
<?php get_template_part(‘template-parts/content’, get_post_type()); ?></div>
<?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”;
}
?>Trevor(Private) September 22, 2020 at 7:50 am #260252I think that the issue is that the selectors all have to be in the results.php template, and not loaded in that external code call. The Infinite Scroll works by asking the results.php file to reload the PHP part of the results.php file that is specified. If that classname is not actually in that file, but is instead inside another file called from within the loop, it won’t be found. Thus, it cannot ‘clear’ them. You may have to grab the code from that external code call and bring it directly inside the resuls.php file.
Trevor(Private) September 22, 2020 at 8:53 am #260279You need to use code back ticks (one before, and one after the code). On my keyboard, a UK Windows keyboard, the key is next to the 1 key in the standard part of the keyboard. If you do this Google search and look at the images, they show various keyboards and where the key is located:
-
AuthorPosts