Forums › Forums › Search & Filter Pro › Search results on home page
- This topic has 10 replies, 2 voices, and was last updated 5 years ago by Trevor.
-
Anonymous(Private) October 16, 2019 at 5:04 pm #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
Anonymous(Private) October 17, 2019 at 8:31 am #223892Hi there the website is in development http://www3.vamos.es
I You will see the filter with no css
Thanks
Anonymous(Private) October 17, 2019 at 10:46 am #223908Sorry, 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(Private) October 17, 2019 at 9:04 pm #224034Possibly, 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(Private) October 18, 2019 at 8:26 am #224050Hi!!! 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(); ?>
-
AuthorPosts