Forums Forums Search & Filter Pro Results showing up twice

Viewing 10 posts - 1 through 10 (of 12 total)
  • Anonymous
    #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
    #260158

    This 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
    #260159

    I’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”;
    }
    ?>

    Anonymous
    #260166

    I tried a hard refresh and this resolves so appears to be a caching issue. Is there a setting somewhere I need to update?

    Anonymous
    #260195

    sorry for all the posts. So if I refresh it removes, the issue seems to be that using ajax to update, it isn’t clearing the result that’s given first at the point that the page loads when filtered – any suggestions?

    Trevor
    #260232
    This reply has been marked as private.
    Anonymous
    #260248
    This reply has been marked as private.
    Trevor
    #260252

    I 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
    #260279

    You 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:

    https://www.google.com/search?q=back+tick+code+key

    Anonymous
    #260281
    This reply has been marked as private.
Viewing 10 posts - 1 through 10 (of 12 total)