Title: Loop within a loop &#8211; comments problem
Last modified: August 19, 2016

---

# Loop within a loop – comments problem

 *  Resolved [extatix](https://wordpress.org/support/users/extatix/)
 * (@extatix)
 * [15 years, 12 months ago](https://wordpress.org/support/topic/loop-within-a-loop-comments-problem/)
 * So I’ve build a piece of code which shows the last 10 posts between the main 
   content of a post (single) and the comments. Problem is: the comments are based
   on the last post from my code. How do I fix this?
 * I use this piece of code:
 *     ```
       <ul>
       <?php $cuery =  new WP_query('posts_per_page=10');
       while ( $cuery->have_posts()) : $cuery->the_post(); ?>
       <li>
       do stuff
       </li>
       <?php endwhile; ?>
       </ul>
       ```
   
 *     ```
       [ content from single ]
       MY CODE
       <?php comments_template('', true); ?>
       [endwhile; endif;]
       ```
   

Viewing 1 replies (of 1 total)

 *  Thread Starter [extatix](https://wordpress.org/support/users/extatix/)
 * (@extatix)
 * [15 years, 12 months ago](https://wordpress.org/support/topic/loop-within-a-loop-comments-problem/#post-1532650)
 * `wp_reset_query();` is the solution

Viewing 1 replies (of 1 total)

The topic ‘Loop within a loop – comments problem’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [extatix](https://wordpress.org/support/users/extatix/)
 * Last activity: [15 years, 12 months ago](https://wordpress.org/support/topic/loop-within-a-loop-comments-problem/#post-1532650)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
