seancojr
4/4/2016 - 12:34 AM

only show results once we have applied some filters From https://wordpress.org/support/topic/hide-results-until-filtered?replies=4

only show results once we have applied some filters

From https://wordpress.org/support/topic/hide-results-until-filtered?replies=4

<?php global $wp_query; ?>

<?php
/**
 * If query contains less than 2 parameters (so basically 1) and this is used on archive.php that probably means we only have the post_type parameter.
 */
if( count($wp_query->query) < 2 ):
?>

	<p>Please select at least one filter above</p>

<?php else: ?>
	<?php
	/**
	 * Yay we have more than 1 parameter so it's probably our filtered taxonomies.
	 * Show the loop!
	 */
	if( have_posts() ): while( have_posts() ): the_post();
	?>

	<article>
		<header>
			<h1><?php the_title(); ?></h1>
		</header>
		<div class="entry">
			<?php the_content(); ?>
		</div>
	</article>

	<?php endwhile; endif; ?>
<?php endif; ?>