How do I hide initial results?

Forums › Forums › Search & Filter Pro › How do I hide initial results?

Viewing 21 post (of 21 total)
  • Trevor
    #44951

    So, it is relatively simple if you are using the Shortcode Display Results method. See the documentation:

    http://www.designsandcode.com/documentation/search-filter-pro/search-results/using-a-shortcode/

    See how it is using a template called results.php?

    This is that file:

    <?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
     *
     */
    
    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();
    		
    		?>
    		<div>
    			<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    			
    			<p><br /><?php the_excerpt(); ?><p>
    			<?php 
    				if ( has_post_thumbnail() ) {
    					echo '<p>';
    					the_post_thumbnail("small");
    					echo '</p>';
    				}
    			?>
    			<p><?php the_category(); ?><p>
    			<p><?php the_tags(); ?><p>
    			<p><small><?php the_date(); ?></small><p>
    			
    		</div>
    		
    		<hr />
    		<?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";
    }
    ?>

    And here is it modified:

    <?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
     *
     */
    
    if ( $query->have_posts() ) {
    	global $searchandfilter;
    	$sf_current_query = $searchandfilter->get(1526)->current_query();
    	if ($sf_current_query->is_filtered()) {
    		?>
    
    		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();
    
    			?>
    			<div>
    				<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    
    				<p><br/><?php the_excerpt(); ?><p>
    					<?php
    					if (has_post_thumbnail()) {
    						echo '<p>';
    						the_post_thumbnail("small");
    						echo '</p>';
    					}
    					?>
    				<p><?php the_category(); ?><p>
    				<p><?php the_tags(); ?><p>
    				<p>
    					<small><?php the_date(); ?></small>
    				<p>
    
    			</div>
    
    			<hr/>
    			<?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";
    }
    ?>

    replace 1526 with the id of your search form.

Viewing 21 post (of 21 total)

Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.