Forums Forums Search & Filter Pro Search results on home page

Viewing 10 posts - 1 through 10 (of 11 total)
  • Anonymous
    #223821

    I need to show the search results on my home page where I have the filter shortcode, is there any chance to do this by ajax? I need no results if user doesn’t use the filter, but when the user clicks in an option then I need to display the results.

    thanks

    Trevor
    #223839

    It depends what Display results Method you have chosen and how your theme or page builder creates the list of posts on the front page. It is possible though, yes.

    Are you able to send me a live link/URL to your home page so I can take a look?

    Anonymous
    #223892

    Hi there the website is in development http://www3.vamos.es

    I You will see the filter with no css

    Thanks

    Anonymous
    #223898

    It’s not working at all, don’t know why, I deactivate all plugins and using clean theme and is not working, it always displays same results….

    Anonymous
    #223908

    Sorry, Now is working but I have to reload the home page to see the results, if I don’t reload page the results are all posts.

    Any idea?

    My code:

    <?php echo do_shortcode ('[searchandfilter id="2611"]'); ?>
    		
    		<?php $args = array('post_type' => 'coche');
    		$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 <?php post_class('col-sm-4 col-md-4'); ?>>
    			    <a class="thumb_rel" href="<?php echo get_permalink();?>"><?php echo get_the_post_thumbnail();?></a>
    			    <span class="posted-on">
    		            <span class="screen-reader-text">Publicado el </span>
    		            <time class="entry-date published"><?php echo get_the_date()?></time>
    		            <span class="tiempo_lectura">Tiempo de lectura <?php echo get_post_meta(get_the_ID(), 'tiempo_de_lectura', true)?>´</span>
    			    </span>
    			    <h4><a class="title_rel" href="<?php echo get_permalink();?>">
    				    <?php if( get_field('titulo_listado_3_noticias') ) { ?>
    				    	<?php the_field ('titulo_listado_3_noticias')?>
    					<?php } else { ?>
    					  <?php the_title (); ?>
    					<?php }?>
    				    </a>
    				</h4>
    			    <hr class="linea-post">
    			    <p><?php echo get_the_excerpt()?></p>
    			</div>
    		<?php endwhile; ?>
    		<?php endif; ?>
    		<?php wp_reset_query(); ?>
    Trevor
    #224026

    Try changing the Ajax Container from #main to .posts

    Anonymous
    #224030

    It works!!!

    One more question, is there any chance to hide posts completely before I use the filter?? So I only get results when press submit?

    Thanks

    Trevor
    #224034

    Possibly, but you will need to figure where to put this code:

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(2611)->current_query();
    if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) {
      echo '<div>Nothing to see here folks!</div>'; 
    } else {
      // your current results template code here - the if have posts bit.
    }
    Anonymous
    #224050

    Hi!!! thanks for the support but I can’t make it work, where do I have to put that code??? If you can help me with this please.

    This is my code:

    <?php echo do_shortcode ('[searchandfilter id="2611"]'); ?>
    
    <?php $args = array('post_type' => 'coche');
    $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(); ?>
    Anonymous
    #224054

    Sorry!! I’ve figured it out and it’s working like a charm!

    Thanks

Viewing 10 posts - 1 through 10 (of 11 total)