Title: stop query_posts
Last modified: August 19, 2016

---

# stop query_posts

 *  [fksr86](https://wordpress.org/support/users/fksr86/)
 * (@fksr86)
 * [18 years ago](https://wordpress.org/support/topic/stop-query_posts/)
 * hey everyone
 * i want something that i don’t know much how to explain, but here we go.
 * i’m using a `$counter` variable, defined before the loop:
 * `<?php $counter = 0; ?>`
 * everypost adds 1 to the counter:
 * `<?php $counter = $counter + 1; ?>`
 * but, if the post is in category 6, it adds one more:
 *     ```
       <?php if (in_category('6')) { ?>
       <?php $counter = $counter + 1; ?>
       ```
   
 * well, i do it because i want that when it reaches 7, it shows up a page:
 * `<?php if(7 == $counter ) : include (TEMPLATEPATH . '/BREAKING-NEWS.php'); endif;?
   >`
 * here is my question: i want to stop `query_posts` after counter reaches 10, but
   i can’t do it by myself. do you guys suggest something?
 * thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [fksr86](https://wordpress.org/support/users/fksr86/)
 * (@fksr86)
 * [18 years ago](https://wordpress.org/support/topic/stop-query_posts/#post-764996)
 * 🙁
 *  [iridiax](https://wordpress.org/support/users/iridiax/)
 * (@iridiax)
 * [18 years ago](https://wordpress.org/support/topic/stop-query_posts/#post-764997)
 * Do you mean ending the loop with an `endwhile;` after $counter equals 10?
 * [http://codex.wordpress.org/The_Loop](http://codex.wordpress.org/The_Loop)

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘stop query_posts’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [iridiax](https://wordpress.org/support/users/iridiax/)
 * Last activity: [18 years ago](https://wordpress.org/support/topic/stop-query_posts/#post-764997)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
