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 › Hide Posts if nothing is selected, then show them
- This topic has 20 replies, 2 voices, and was last updated 4 years, 7 months ago by Javier Martín Balsa.
-
Javier Martín Balsa(Private) January 9, 2020 at 10:19 am #230475
Hi there I need to hide some posts in a page where I’ve got a filter, and then when I select some options in the filter I want to show them.
This posts are a copy so when nothing is filtered I don´t want to show them.
Thanks
Trevor Moderator(Private) January 9, 2020 at 10:47 am #230480Any 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?
Javier Martín Balsa(Private) January 9, 2020 at 11:01 am #230485I’ve send you the dropbox links but it seems this is not working right
Trevor Moderator(Private) January 9, 2020 at 11:31 am #230492I do not see the links posted here? How did you send them?
Javier Martín Balsa(Private) January 9, 2020 at 11:34 am #230494I posted here like an image with the <img”source dropbox”> but it looks like is not working, I also send you a link of my website but it din’t worked as well
Trevor Moderator(Private) January 9, 2020 at 11:40 am #230496It needs to be an actual link (http….) not an img…source…
Javier Martín Balsa(Private) January 9, 2020 at 11:42 am #230498Javier Martín Balsa(Private) January 9, 2020 at 11:43 am #230500Trevor Moderator(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.
Javier Martín Balsa(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
The topic ‘Hide Posts if nothing is selected, then show them’ is closed to new replies.