Adriano Varlotta
Adriano Varlotta

Reputation: 525

if is search page, dont show the loop

i have this code, its working great, but i need if is_search dont show this the loop.

Because when i am on search page he shows 2 times the loop...

Anyone?

<?php  
if ( is_product_category( 'masculino' ) ) {
query_posts("cat=20");
} elseif ( is_product_category( 'feminino' ) ) {
query_posts("cat=21");
} elseif ( is_product_category( 'lancamentos' ) ) {
query_posts("cat=22");
} elseif ( is_product_category( 'tabacaria' ) ) {
query_posts("cat=40");
} elseif ( is_product_category( 'acessorios' ) ) {
query_posts("cat=41");
} else {
} 
?>
<?php $count = 1; ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <div id="post-<?php the_ID(); ?>" class="categoriachamada<?php echo $count; ?>">
        <div class="overlaygreen"></div>
        <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
        <?php the_post_thumbnail();?></a>
        <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
        <?php the_content(); ?>
    </div><!-- #post-id -->
    <?php $count++; ?>
    <?php endwhile; else :?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
     <?php endif; ?>
    <?php wp_reset_query(); ?>

Thanks

Upvotes: 1

Views: 591

Answers (1)

Ranjith
Ranjith

Reputation: 2819

For that you have the check the condition for both is satisfied.

<?php if ( have_posts() && !is_search() ) : while ( have_posts() ) : the_post(); ?>

instead of

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

Upvotes: 1

Related Questions