Title: Excluding specific posts from a custom WP_Query()
Last modified: August 19, 2016

---

# Excluding specific posts from a custom WP_Query()

 *  Resolved [stevechatterton](https://wordpress.org/support/users/stevechatterton/)
 * (@stevechatterton)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/excluding-specific-posts-from-a-custom-wp_query/)
 * I’ve got a bit of a problem I’m trying to resolve on this page:
    [http://www.thelitreview.com/](http://www.thelitreview.com/)
 * It’s a site about books, and the site’s posts are exclusively split up between
   fiction, non-fiction & site news. I’m using a custom WP_Query function to keep
   the categories separate from each other. For example, this is how the fiction
   category looks under the hood:
 *     ```
       <?php $my_query1 = new WP_Query('category_name=fiction&showposts=7');
       while ($my_query1->have_posts()) : $my_query1->the_post();
       $do_not_duplicate1 = $post->ID; ?>
       ```
   
 * Now I want to be able to specify certain posts to be excluded from front page
   display. I’ve tried modifying the parameters to something like this:
 * `$my_query1 = new WP_Query('category_name=fiction&showposts=7&p=-1,-3,-7');`
 * But the results have been disastrous. Does anyone know what I’m doing wrong? 
   Better yet, does anyone know how to do it right? I’d really appreciate it if 
   some kind soul could help point me in the right direction.
 * Thanks.

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/excluding-specific-posts-from-a-custom-wp_query/#post-1406037)
 * Did you try the `post__not_in` argument?
 * See [query_posts()](http://codex.wordpress.org/Template_Tags/query_posts).
 *  Thread Starter [stevechatterton](https://wordpress.org/support/users/stevechatterton/)
 * (@stevechatterton)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/excluding-specific-posts-from-a-custom-wp_query/#post-1406128)
 * Thanks, MichaelH.
 * I changed my statement to this:
 * <?php
 * $args=array(
    ‘cat’=>1, ‘caller_get_posts’=>7, ‘post__not_in’ => array(1111,1115));
 * $my_query1 = new WP_Query($args);
    while ($my_query1->have_posts()) : $my_query1-
   >the_post(); $do_not_duplicate1 = $post->ID; ?>
 * And it does exactly what I need.
 * Thanks!

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

The topic ‘Excluding specific posts from a custom WP_Query()’ is closed to new replies.

## Tags

 * [custom-query](https://wordpress.org/support/topic-tag/custom-query/)
 * [exclude post](https://wordpress.org/support/topic-tag/exclude-post/)
 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [stevechatterton](https://wordpress.org/support/users/stevechatterton/)
 * Last activity: [16 years, 3 months ago](https://wordpress.org/support/topic/excluding-specific-posts-from-a-custom-wp_query/#post-1406128)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
