• My index.php has 2 main loops, the first loop reads out say some 8 posts and then breaks the loop; then the second loop continues from where the first loop stopped:

    <?php /***************** FIRST Loop ******************/?>
    <?php if (have_posts()):?>
    	<?php while (have_posts())  : the_post(); update_post_caches($posts);?>
    ......Do Stuff
    ......and BREAK the loop say after 8 posts
    	<?php endwhile; ?>
    	<?php   else : ?>
    	  <div class="errorbox">
    		<?php
    		  _e('Sorry, no posts matched your criteria.', 'inove');?>
    	  </div>
    <?php  endif;?>
    
    <?php /***************** SECOND Loop ******************/?>
    <?php if (have_posts()):?>
    	<?php while (have_posts()): the_post();update_post_caches($posts);?>
    ......Do Stuff
    	<?php endwhile; ?>
    <?php  endif;?>

    and this works perfectly.

    But if just adding the following code at the beginning of the loop (inside the loop):
    <?php if (in_category('3')) continue; ?>

    screws up everything, in a way it looks like the loop is rewinded.
    Any hint?

Viewing 2 replies - 1 through 2 (of 2 total)
  • If you are trying to just display that category in the loop. Try use this.

    <?php
    
    			$temp = $wp_query;
    
    			$wp_query= null;
    
    			$wp_query = new WP_Query();
    
    			$wp_query->query('cat=3&showposts=10'.'&paged='.$paged);
    
    			?>
    
    			<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
    Thread Starter Blutarsky

    (@blutarsky)

    Ok, but I need to break the loop after a few posts and start again with another layout…. how do I keep the pointer to the last read record?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Does in_category(”) screws the_Loop ???’ is closed to new replies.