Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro Search results on home page (no results)

Viewing 4 posts - 1 through 4 (of 4 total)
  • Javier Martín Balsa
    #227913

    Hi there I opened a ticket closed with success https://support.searchandfilter.com/forums/topic/search-results-on-home-page/page/2/#post-224056

    But I found that when I filter with no results there is no message of No Results.

    The Code:

    <?php	
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(2611)->current_query();
    if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) {
      echo ''; 
    } else { ?>
    
    <?php $args = array('post_type' => 'renting');
    $args['search_filter_id'] = 2611;
    $query = new WP_Query($args);?>
    	<?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); // run the loop ?>
    
    <div class="car col-sm-6 col-md-4 wow fadeIn" data-wow-duration="1s" data-wow-delay="0.3s">
    		<a class="redirectClick" href="<?php the_permalink(); ?>">
    			<div class="item item-price" >
    			    <span class="marca"><?php the_title (''); ?></span>
    			    <span class="vehicle-finish"><?php the_field ('modelo'); ?></span>
    			    <div class="image"><img src="<?php the_post_thumbnail_url( $size ); ?>" /></div>
    			    <span class="precio categoria"><?php the_field ('precio'); ?><span class="euros-al-mes">€/mes</span><span class="iva-incluido">IVA incluido</span></span>
    			    <div class="price-canceled"></div>
    			    <div class="row categorias">
    				    <div class="col-xs-7 kilometros categoria"><img class="icono-kilometros" src="/wp-content/uploads/2019/04/icon-kilometer.svg" alt=""><?php the_field ('km_anuales'); ?><span class="km-anuales">km anuales</span></div>
    				    <div class="col-xs-5 meses categoria"><img class="icono-meses" src="/wp-content/uploads/2019/04/icon-clock.svg" alt=""><?php the_field ('meses'); ?><span class="meses">meses</span></div>
    			    </div>
    			</div>
    		</a>
    	</div>
    
    <?php endwhile; ?>
    <?php endif; ?>
    <?php wp_reset_query(); ?>
    

    I need the filter to show no results until I press the search button, and if there are no results to show a “no results phrase”

    Thanks
    Any ideas?

    Trevor Moderator
    #227935

    These two lines:

    <?php endwhile; ?>
    <?php endif; ?>

    Would need to be something like:

    <?php endwhile;
    else: ?>
    <div class="no-results">No Results Found</div>
    <?php endif; ?>
    Javier Martín Balsa
    #227964

    Thanks!!!!! it worked!

    Trevor Moderator
    #227967

    Thanks for letting me know. I will close this thread for now.

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

The topic ‘Search results on home page (no results)’ is closed to new replies.