Forums Forums Search & Filter Pro Display 'no results found'

Viewing 3 posts - 1 through 3 (of 3 total)
  • Anonymous
    #130718

    Hi there,

    I have an archive page with two checkbox filters that have an AND relationship. The filter works fine although I am having trouble displaying a ‘no posts found’ message when the filter criteria returns no posts.

    Thanks,
    Braden

    My code:
    <div class=”row”>
    <div class=”col-xl-3 col-lg-12 left-sidebar adjust-space”>
    <div class=”filter-wrapper”>
    <div class=”button-filter”>
    <?php echo do_shortcode(‘[searchandfilter id=”43″]’); ?>
    </div>
    </div>
    </div>
    <div class=”col-xl-9 col-lg-12 bg-white”>
    <div class=”featured-section”>
    <div class=”container-fluid no-padding”>
    <div id=”filter-results” class=”row”>

    <?php
    $args = array(‘post_type’ => ‘clients’);
    $args[‘search_filter_id’] = 43;
    $query = new WP_Query( $args );
    ?>

    <?php if ( have_posts( $query->have_posts() ) ) : ?>

    <?php while ( $query->have_posts() ) : $query->the_post(); ?>

    <div class=”col-lg-3 col-md-4 col-sm-6 col-xs-12 item”>

    <?php
    /*
    * Include the Post-Format-specific template for the content.
    * If you want to override this in a child theme, then include a file
    * called content-___.php (where ___ is the Post Format name) and that will be used instead.
    */
    get_template_part( ‘loop-templates/content-featured-tile’, get_post_format() );
    ?>

    </div>

    <?php endwhile; ?>

    <?php else : ?>

    <?php get_template_part( ‘loop-templates/content-none’, get_post_format() ); ?>

    <?php endif; wp_reset_postdata(); ?>

    </div>
    </div>
    </div>
    </div>
    </div>

    Trevor
    #130754

    It sort of looks right. Our shortcode method uses a similar template, so why not take a look at that? In the plugin folder, you will find a templates folder, take a look at the results.php file.

    Anonymous
    #130857

    Thanks for pointing me in the right direction. I needed to set a results-selector and fix the if statement below.

    <?php if ( have_posts( $query->have_posts() ) ) : ?>

    to

    <?php if ( $query->have_posts() ) : ?>

    Cheers,
    Braden

Viewing 3 posts - 1 through 3 (of 3 total)