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

Viewing 9 posts - 21 through 29 (of 29 total)
  • Trevor
    #231801
    This reply has been marked as private.
    Anonymous
    #231803
    This reply has been marked as private.
    Trevor
    #231805
    This reply has been marked as private.
    Anonymous
    #231807

    Thanks!!!!!

    Trevor
    #231815
    This reply has been marked as private.
    Anonymous
    #231819
    This reply has been marked as private.
    Trevor
    #231821

    Might be nice to see, glad it worked!

    Anonymous
    #231823

    Here is my code, just replace the <?php the_title (); ?> with your code (thumbnail, tags, categories..) and there you go.

    <?php
    /**
     * Search & Filter Pro 
     *
     * Sample Results Template
     * 
     * @package   Search_Filter
     * @author    Ross Morsali
     * @link      http://www.designsandcode.com/
     * @copyright 2015 Designs & Code
     * 
     * Note: these templates are not full page templates, rather 
     * just an encaspulation of the your results loop which should
     * be inserted in to other pages by using a shortcode - think 
     * of it as a template part
     * 
     * This template is an absolute base example showing you what
     * you can do, for more customisation see the WordPress docs 
     * and using template tags - 
     * 
     * http://codex.wordpress.org/Template_Tags
     *
     */
    
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(5555)->current_query();
    if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { ?>
    
    <?php
    	  // set up or arguments for our custom query
    	  $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
    	  $query_args = array(
    	    'post_type' => 'renting',
    	    'post__not_in' => array(4894, 4898, 4900, 4902, 4896),
    	    'tax_query' => array(
    	    'relation' => 'AND',
    	    array(
    	        'taxonomy' => 'mostrar-en-parrilla',
    	        'field'    => 'slug',
    	        'terms'    => 'si',
    	    ),
    	
    	),
    	    'posts_per_page' => -1,
    	    'paged' => $paged
    	  );
      // create a new instance of WP_Query
      $the_query = new WP_Query( $query_args );
    ?>
    
    	<?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); // run the loop ?>
    		<?php the_title (); ?>
    
    <?php endwhile; ?>
    <?php endif; ?>
    <?php wp_reset_query(); ?>
      
    <?php } else {
    	
    	if ( $query->have_posts() )
    {
    	?>
    	
    	Found <?php echo $query->found_posts; ?> Results<br />
    	Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />
    	
    	<div class="pagination">
    		
    		<div class="nav-previous"><?php next_posts_link( 'Older posts', $query->max_num_pages ); ?></div>
    		<div class="nav-next"><?php previous_posts_link( 'Newer posts' ); ?></div>
    		<?php
    			/* example code for using the wp_pagenavi plugin */
    			if (function_exists('wp_pagenavi'))
    			{
    				echo "<br />";
    				wp_pagenavi( array( 'query' => $query ) );
    			}
    		?>
    	</div>
    	
    	<?php
    	while ($query->have_posts())
    	{
    		$query->the_post();
    		
    		?>
    			
    			<?php the_title (); ?>
    
    		<?php
    	}
    	?>
    	Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />
    	
    	<div class="pagination">
    		
    		<div class="nav-previous"><?php next_posts_link( 'Older posts', $query->max_num_pages ); ?></div>
    		<div class="nav-next"><?php previous_posts_link( 'Newer posts' ); ?></div>
    		<?php
    			/* example code for using the wp_pagenavi plugin */
    			if (function_exists('wp_pagenavi'))
    			{
    				echo "<br />";
    				wp_pagenavi( array( 'query' => $query ) );
    			}
    		?>
    	</div>
    	<?php
    }
    else
    {
    	echo "No Results Found";
    }
    }
    ?>
    Trevor
    #231825

    Cool. Thanks for sharing. I will close this thread for now.

Viewing 9 posts - 21 through 29 (of 29 total)