Title: Avoiding Duplicate Posts using query_posts
Last modified: August 20, 2016

---

# Avoiding Duplicate Posts using query_posts

 *  [croco2511](https://wordpress.org/support/users/croco2511/)
 * (@croco2511)
 * [15 years ago](https://wordpress.org/support/topic/avoiding-duplicate-posts-using-query_posts/)
 * I have two custom fields, one is availability-ebook, the other availability-printbook.
   They are both set to ‘Coming Soon’ for books not published yet.
 * On a Coming Soon page with custom template, I want to call all book pages set
   to ‘Coming Soon’ if the book’s not published yet.
    How can I avoid duplicate 
   posts because both the ebook and printbook availability are set to ‘Coming Soon’.
 * My query so far:
 *     ```
       <?php
       //The Query
       query_posts('post_type=page&order=ASC&orderby=date&meta_value=Coming Soon&posts_per_page=-1');
   
       //The Loop
       if ( have_posts() ) : while ( have_posts() ) : the_post();?>
       ```
   
 * I know all about avoiding duplicate posts with two loops. However, if I do 2 
   loops, I can get the books to show up in the order of their release date, cause
   first it runs through one loop say for all print books, and in the second loop
   then for all ebooks.
 * So how can I avoid duplicate posts running only 1 loop/query?

Viewing 1 replies (of 1 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years ago](https://wordpress.org/support/topic/avoiding-duplicate-posts-using-query_posts/#post-2096632)
 * include the `meta_key` into the query?
 * [http://codex.wordpress.org/Function_Reference/WP_Query#Custom_Field_Parameters](http://codex.wordpress.org/Function_Reference/WP_Query#Custom_Field_Parameters)

Viewing 1 replies (of 1 total)

The topic ‘Avoiding Duplicate Posts using query_posts’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/alchymyth/)
 * Last activity: [15 years ago](https://wordpress.org/support/topic/avoiding-duplicate-posts-using-query_posts/#post-2096632)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
