Title: Exclude a Page from query post function
Last modified: August 19, 2016

---

# Exclude a Page from query post function

 *  [wireframe74](https://wordpress.org/support/users/wireframe74/)
 * (@wireframe74)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/exclude-a-page-from-query-post-function/)
 * Hi I have a query post function that is grabbing child pages for a gallery that
   I have set up here: [Gallery](http://218.185.38.19/~roplayco/dev/gallery/)
 * I really want to exclude a page from the 2nd loop on page as I have 2 loops running
   and an image is repeating itself in gallery..
 * I have initial loop with a limit of one to grab the initial image from gallery
   and the second one which is in a hidden div which retrieves all images.
 * I have looked at codex but it mentions info on how to exclude categories and 
   not pages..I have tried appending this to my query post to achieve this with 
   no luck ‘page_id=-45’
 * Below are my two loops
 *     ```
       <p>To view our gallery of exciting Roplay products,
       please  <?php
       query_posts(array('showposts' => 1, 'post_parent'=> 40, 'post_type' => 'page'));
       while (have_posts()) {
       the_post();
       ?>
       <a href="<? echo get('gallery_image'); ?>" rel="lightbox-gallery" title="<?php the_title(); ?>" id="gallery">click here...</a>
   
       <?php }
   
       wp_reset_query(); //Restore Global Post data
   
       ?>
   
       <?php
       query_posts(array('showposts' => 100, 'post_parent'=> 40, 'post_type' => 'page','page_id=-45'));
       while (have_posts()) {
       the_post();
       ?>
        <div style="display:none;"><a href="<? echo get('gallery_image'); ?>" rel="lightbox-gallery" title="<?php the_title(); ?>">click here...</a></div>
   
       <?php }
   
       wp_reset_query(); //Restore Global Post data
   
       ?>
   
       <?php
       query_posts(array('showposts' => 100, 'post_parent'=> 40, 'post_type' => 'page','p=-45'));
       while (have_posts()) {
       the_post();
       ?>
       ```
   

Viewing 1 replies (of 1 total)

 *  [Shane G.](https://wordpress.org/support/users/shane-g-1/)
 * (@shane-g-1)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/exclude-a-page-from-query-post-function/#post-1498300)
 * Hi,
 * Check with these plugins:
 * [http://wordpress.org/extend/plugins/exclude-pages/](http://wordpress.org/extend/plugins/exclude-pages/)
   
   [http://wordpress.org/extend/plugins/simply-exclude/](http://wordpress.org/extend/plugins/simply-exclude/)
 * Also refer this article:
 * [http://codex.wordpress.org/Function_Reference/query_posts](http://codex.wordpress.org/Function_Reference/query_posts)
 * Thanks,
 * Shane G.

Viewing 1 replies (of 1 total)

The topic ‘Exclude a Page from query post function’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Shane G.](https://wordpress.org/support/users/shane-g-1/)
 * Last activity: [16 years, 1 month ago](https://wordpress.org/support/topic/exclude-a-page-from-query-post-function/#post-1498300)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
