2014-05-24 38 views
1

我有此代碼,其工作很好,但我需要如果is_search不顯示此循環。如果是搜索頁面,不顯示循環

因爲當我搜索頁面上顯示,他2次循環...

有人嗎?

<?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(); ?> 

感謝

回答

1

對於你有檢查這兩個條件滿足。

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

代替

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

非常感謝!效果很好! –

+0

歡迎..... :) – Ranjith

相關問題