Forums Forums Search & Filter Pro Hide Posts if nothing is selected, then show them

Viewing 10 posts - 1 through 10 (of 21 total)
  • Anonymous
    #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
    #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?

    Anonymous
    #230485

    I’ve send you the dropbox links but it seems this is not working right

    Trevor
    #230492

    I do not see the links posted here? How did you send them?

    Anonymous
    #230494

    I 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
    #230496

    It needs to be an actual link (http….) not an img…source…

    Trevor
    #230637

    I 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
    #230647

    This 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>
Viewing 10 posts - 1 through 10 (of 21 total)