Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jonathandejong

    (@jonathandejong)

    Hi Mike,

    Not sure I understand what you mean..
    Do you want to “disable” the archive that has no filter applied to it?

    Thread Starter mikelast

    (@mikelast)

    Hi thanks for getting back to me, OK – if you imagine that you have 200 results that would appear in a long list down the page, I want to hide all of these results until the user has selected at least 2 options to filter those 200 results by. Once they have started filtering then the results would appear on the page.

    hope that makes sense

    mike

    Plugin Author Jonathandejong

    (@jonathandejong)

    Hey Mike,

    Alright I see. You could achieve this with some custom code in your archive.php.
    Here’s a liiiittle hacky solution but I think it should work fine.

    <?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; ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hide results until filtered’ is closed to new replies.