Support » How-To and Troubleshooting » Does in_category(”) screws the_Loop ???

Does in_category(”) screws the_Loop ???

  • 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">
    		  _e('Sorry, no posts matched your criteria.', 'inove');?>
    <?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.

    			$temp = $wp_query;
    			$wp_query= null;
    			$wp_query = new WP_Query();
    			<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>

    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.