Forums › Forums › Search & Filter Pro › Hide Posts if nothing is selected, then show them
- This topic has 20 replies, 2 voices, and was last updated 4 years, 10 months ago by Anonymous.
-
Trevor(Private) January 9, 2020 at 10:47 am #230480
Any annotated screenshots you can make to help show me what you want would be appreciated. You will need to upload images to an external file sharing site, like dropbox, and share the link(s) with me.
Are you able to send me a live link/URL to your search page so I can take a look?
Trevor(Private) January 10, 2020 at 11:56 am #230637I see. The logic then would be:
if no filter show these posts
else if filter selected do not show those posts but show these instead.What Display Results method does the form use? If it use shortcode, this should be easy, if it uses another method, you may need to edit the theme templates. If the page uses a Page Builder to make the content, then this may not be possible.
Anonymous(Private) January 10, 2020 at 12:14 pm #230647This is my code, using a shortcode and a query. The display results option is Custom and using ajax.
<?php echo do_shortcode ('[searchandfilter id="5437"]'); ?> <div class="clearfix"></div> <div class="filtro-cars" data-wow-duration="1s" data-wow-delay="0.3s"> <?php $args = array('post_type' => 'renting'); $args['search_filter_id'] = 5437; $query = new WP_Query($args);?> <?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); // run the loop ?> <div class="car main-car col-xs-12 col-sm-12 col-md-6 wow fadeIn no-padding" data-wow-duration="0.4s" data-wow-delay="0.3s"> <a class="redirectClick" href="<?php the_permalink(); ?>"> <div class="item item-price" > <div class="car-shadow"> <div class="image"><?php the_post_thumbnail( 'car-related' ); ?></div> <div class="data"> <div class="row"> <div class="col-md-7 col-lg-8"> <span class="marca"><?php the_title (''); ?></span> <span class="vehicle-finish"><?php the_field ('modelo'); ?></span> </div> <div class="col-md-5 col-lg-4"> <div class="combustible hidden-xs hidden-sm"> <?php $count = 0; $your_repeater = get_field('caracteristicas'); if($your_repeater){ while( have_rows('caracteristicas') ): the_row(); $count++; $my_field = get_sub_field('icono'); $my_content= get_sub_field('texto'); if ($count == 4) { ?> <img width="14" src="<?php echo get_template_directory_uri(); ?>/inc/img/front/<?php echo $my_field; ?>.svg" /> <?php echo $my_content; ?> <?php } endwhile; } ?> </div> </div> </div> <div class="row"> <div class="col-sm-7"> <div class="precio-card"><?php the_field ('precio'); ?>€/mes<br> <span class="iva-incluidos">IVA incluido</span> </div> </div> <div class="col-sm-5 info"> <div class="kilometros"> <?php the_field ('km_anuales'); ?><span class="km-anuales">km anuales |</span> </div> <div class="meses"> <?php the_field ('meses'); ?><span class="meses">meses</span> </div> </div> </div> </div> </div> </div> </a> </div> <?php endwhile; else: ?> <div class="no-results">No hemos encontrado resultados, prueba con otros criterios de filtro.</div> <?php endif; ?> <?php wp_reset_query(); ?> </div>
-
AuthorPosts