Title: Query_posts infinite loop?
Last modified: August 19, 2016

---

# Query_posts infinite loop?

 *  Resolved [itsageek](https://wordpress.org/support/users/itsageek/)
 * (@itsageek)
 * [18 years ago](https://wordpress.org/support/topic/query_posts-infinite-loop/)
 * Could anybody tell me why this is looping infinitely?
 *     ```
       <?php get_header(); ?>
   
       <div id="content">
         <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
         <div class="post" id="post-<?php the_ID(); ?>">
           <h2>
             <?php the_title(); ?>
           </h2>
           <small><?php the_time(__('M jS, Y','branfordmagazine')); ?> | <?php _e('By','branfordmagazine');?> <?php the_author_posts_link('namefl');?>
       	<?php edit_post_link('Edit', ' | ', ''); ?>
           </small>
           <div class="entry">
              <?php the_content("<p class=\"serif\">" . __('Read the rest of this page', 'branfordmagazine') ." &raquo;
       "); ?>
   
             <?php wp_link_pages("<strong>" . __('Pages', 'branfordmagazine') . ":</strong>", '
       ', __('number','branfordmagazine')); ?>
           </div>
   
         <?php comments_template(); ?>
   
         <?php endwhile; else: ?>
         <?php endif; ?>
   
         <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
       	  <?php $taglist = get_the_tags(); ?>
       	  <?php $tagcount = 0;?>
       	  <?php foreach($taglist as $taglists){
       		if ($tagcount == 0){
       			$myposts0 = query_posts("tag=VAMP&showposts=1");
       			$tagcount++;
       		}
       		elseif ($tagcount == 1){
       			$myposts1 = query_posts("tag=DYMAX&showposts=1");
       			$tagcount++;
       		}
       		elseif ($tagcount == 2){
       			$myposts2 = query_posts("tag=DGA&showposts=1");
       			$tagcount++;
       		}
       		else{
       			break;
       		}
       	 };
       	  ?>
   
       	  <div id="lefttag">
       		<ul>
       		<?php foreach($myposts0 as $mpost0) { ?>
       			<li><a href="<?php echo get_permalink($mpost0->ID); ?>"> <?php echo $mpost0->post_title; ?></a></li>
       		<? } ?>
       		</ul>
       	  </div>
   
       	  <div id="middletag">
       		<ul>
       		<?php foreach($myposts1 as $mpost1) {?>
       			<li><a href="<?php echo get_permalink($mpost1->ID); ?>"> <?php echo $mpost1->post_title; ?></a></li>
       		<? } ?>
       		</ul>
       	  </div>
   
       	  <div id="righttag">
       		<ul>
       		<?php foreach($myposts2 as $mpost2) {?>
       			<li><a href="<?php echo get_permalink($mpost2->ID); ?>"> <?php echo $mpost2->post_title; ?></a></li>
       		<? } ?>
       		</ul>
       	  </div>
   
       	  <?php endwhile; else: ?>
       	  <?php endif; ?>
   
       </div>
       </div>
       <?php get_sidebar(); ?>
       <?php get_footer(); ?>
       ```
   
 * it shows up as
    bullet – post bullet – post… infinitely
 * If you’d like to check out the actual site it’s [http://blog.tippingpointlabs.com/?p=688](http://blog.tippingpointlabs.com/?p=688)
   but please click stop as soon as you can, it will continue to load.

Viewing 1 replies (of 1 total)

 *  Thread Starter [itsageek](https://wordpress.org/support/users/itsageek/)
 * (@itsageek)
 * [18 years ago](https://wordpress.org/support/topic/query_posts-infinite-loop/#post-764031)
 * gasp… fixed it…
 * extraneous while loop before the foreach

Viewing 1 replies (of 1 total)

The topic ‘Query_posts infinite loop?’ is closed to new replies.

## Tags

 * [infinite loop](https://wordpress.org/support/topic-tag/infinite-loop/)
 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)
 * [tags](https://wordpress.org/support/topic-tag/tags/)

 * 1 reply
 * 1 participant
 * Last reply from: [itsageek](https://wordpress.org/support/users/itsageek/)
 * Last activity: [18 years ago](https://wordpress.org/support/topic/query_posts-infinite-loop/#post-764031)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
