Title: Problem with showposts
Last modified: August 19, 2016

---

# Problem with showposts

 *  Resolved [misterpatrick67](https://wordpress.org/support/users/misterpatrick67/)
 * (@misterpatrick67)
 * [17 years ago](https://wordpress.org/support/topic/problem-with-showposts/)
 * Hello all,
 * I am running two loops because I have some wacky CSS. In any case, there is something
   weird happening with my code. I need the first loop to show three unique posts
   and then the final loop to show just one unique post from the same category. 
   It’s like I need some sort of limiter on the second loop. Here’s what I have:
 *     ```
       <?php $my_query = new WP_Query('category_name=News&showposts=4');
         while ($my_query->have_posts()) : $my_query->the_post();
         $do_not_duplicate[] = $post->ID ?>
   
           <!-- Do stuff... -->
         <?php endwhile; ?>
   
           <!-- Do other stuff... -->
       <?php if (have_posts()) : while (have_posts()) : the_post();
        if (in_array($post->ID, $do_not_duplicate)) continue;
        update_post_caches($posts); ?>
          <!-- Do stuff... -->
         <?php endwhile; endif; ?>
       ```
   
 * Thanks!

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years ago](https://wordpress.org/support/topic/problem-with-showposts/#post-1088455)
 * Try wp_reset_query() after the first endwhile
 *  Thread Starter [misterpatrick67](https://wordpress.org/support/users/misterpatrick67/)
 * (@misterpatrick67)
 * [17 years ago](https://wordpress.org/support/topic/problem-with-showposts/#post-1088483)
 * Thanks. I couldn’t get that to work, but stripped out some other code and it 
   worked fine. I’m not sure why but it did. Weird. Thanks!

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

The topic ‘Problem with showposts’ is closed to new replies.

## Tags

 * [multiple loops](https://wordpress.org/support/topic-tag/multiple-loops/)
 * [showposts](https://wordpress.org/support/topic-tag/showposts/)

 * 2 replies
 * 2 participants
 * Last reply from: [misterpatrick67](https://wordpress.org/support/users/misterpatrick67/)
 * Last activity: [17 years ago](https://wordpress.org/support/topic/problem-with-showposts/#post-1088483)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
