Title: Avoiding Duplicate Posts Query Issue
Last modified: August 19, 2016

---

# Avoiding Duplicate Posts Query Issue

 *  Resolved [jcalabro](https://wordpress.org/support/users/jcalabro/)
 * (@jcalabro)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/avoiding-duplicate-posts-query-issue/)
 * Hi all,
 * I’m having a problem avoiding duplicate posts. It seems that my second query 
   accounts for the post it’s avoiding. So what’s happening is that if i query showposts
   =4, it only show 3! Very annoying.
 * Any ideas how i can fix this? Or another way of avoiding dups?
 * ‘<div class=”entry”>
 * <?php query_posts(‘cat=3,4,5&showposts=1’); $ids = array(); ?>
    <?php if (have_posts()):?
   > <?php while (have_posts()) : the_post(); ?> <?php $ids[] = get_the_ID(); ?>
   <div class=”date”><?php the_date();?></div>
 * </h1>
    <?php the_excerpt(); ?> <div class=”author”> <?php if ( is_category(‘creative’)){
   echo ‘<div class=”creative”>[](https://wordpress.org/support/topic/avoiding-duplicate-posts-query-issue/get_option(\&apos;home\&apos;);/creative/?output_format=md)
   </div>’; } ?> <!–Posted by <?php the_author(); ?>–> </div>
 *  <?php endwhile; ?>
    <?php else : ?>
 *  <p>Sorry, we are working on new posts as we speak! :)</p>
 *  <?php endif; ?>
 * </div>
 * <?php
    query_posts(“showposts=4&cat=3,4,5,6”); while (have_posts()) : the_post();
   if (!in_array($post->ID, $ids)) { ?> <h3>“><?php the_title(); ?></h3> <?php }
   endwhile; ?>’

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/avoiding-duplicate-posts-query-issue/#post-1152782)
 * [http://codex.wordpress.org/The_Loop#Multiple_Loops](http://codex.wordpress.org/The_Loop#Multiple_Loops)
 *  Thread Starter [jcalabro](https://wordpress.org/support/users/jcalabro/)
 * (@jcalabro)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/avoiding-duplicate-posts-query-issue/#post-1152801)
 * Ahh – Thanks a bunch!

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

The topic ‘Avoiding Duplicate Posts Query Issue’ is closed to new replies.

## Tags

 * [duplicate posts](https://wordpress.org/support/topic-tag/duplicate-posts/)
 * [get_the_id](https://wordpress.org/support/topic-tag/get_the_id/)
 * [multiple loops](https://wordpress.org/support/topic-tag/multiple-loops/)
 * [query](https://wordpress.org/support/topic-tag/query/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [jcalabro](https://wordpress.org/support/users/jcalabro/)
 * Last activity: [16 years, 10 months ago](https://wordpress.org/support/topic/avoiding-duplicate-posts-query-issue/#post-1152801)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
