Title: Infinte loop problem
Last modified: August 19, 2016

---

# Infinte loop problem

 *  Resolved [formica](https://wordpress.org/support/users/formica/)
 * (@formica)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/infinte-loop-problem/)
 * Having problems with some php
 * Attempting to:
 * if in certain parent category, dynamically get the child category then list it’s
   posts or if in other parent category display something else.
 * My bad php is letting me down and I’m creating an infinite loop – could someone
   please set me right
 *     ```
       <?php while (have_posts()) : the_post(); ?>
   
       			  <?php if (in_category('something')) { ?>
   
                                       <?php
                                       if (is_category( )) {
                                         $cat = get_query_var('cat');
                                         $yourcat = get_category ($cat);
                                        }
                                       ?>
   
                                  		<?php query_posts('category_name='.$yourcat->slug.'&showposts=20'); ?>
                                       <li><a href="<?php the_permalink(); ?>">
                                       <?php the_title(); ?>
                                       </a></li>
   
       				<?php } else { ?>
   
                       <?php dynamic_sidebar( 'primary-widget-area' ); ?>	
   
                       <?php } ?>
   
          <?php endwhile; ?>
       ```
   

Viewing 1 replies (of 1 total)

 *  Thread Starter [formica](https://wordpress.org/support/users/formica/)
 * (@formica)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/infinte-loop-problem/#post-1878497)
 * Doh!
 * Sorry solved it myself. Was simply missing off the:
 * `<?php wp_reset_query(); ?>`

Viewing 1 replies (of 1 total)

The topic ‘Infinte loop problem’ is closed to new replies.

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 1 participant
 * Last reply from: [formica](https://wordpress.org/support/users/formica/)
 * Last activity: [15 years, 5 months ago](https://wordpress.org/support/topic/infinte-loop-problem/#post-1878497)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
