Title: Query_posts exclude page
Last modified: August 19, 2016

---

# Query_posts exclude page

 *  Resolved [treelovinhippie](https://wordpress.org/support/users/treelovinhippie/)
 * (@treelovinhippie)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/query_posts-exclude-page/)
 * Hi
 * I’m running this code to list out pages (need to for a particular implementation):
 * `query_posts('post_type=page')`
 * However I’d like to exclude the pages named “logo” and “about” from the query
   loop.
 * How do I add that into the query?
 * … also, how would I get the query to display two particular pages, e.g:
 * `query_posts('post_type=page&pagename=logo,about')`
 * cheers

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/query_posts-exclude-page/#post-1476224)
 * Figure out the page ids for those two pages and use:
 *     ```
       //replace the 3,8 with your page ids
       $args=array(
         'post__not_in' => array(3,8),
         'post_type' => 'page',
         'post_status' => 'publish',
       );
       query_posts($args);
       ```
   
 * Related:
    [How do I determine a Post, Page, Category, Tag, Link, Link Category, or User ID?](http://codex.wordpress.org/FAQ_Working_with_WordPress#How_do_I_determine_a_Post.2C_Page.2C_Category.2C_Tag.2C_Link.2C_Link_Category.2C_or_User_ID.3F)
 *  Thread Starter [treelovinhippie](https://wordpress.org/support/users/treelovinhippie/)
 * (@treelovinhippie)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/query_posts-exclude-page/#post-1476226)
 * Thanks, though is there any way to do it based off pagename/slugs?
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/query_posts-exclude-page/#post-1476233)
 * [Function_Reference/get_page_by_path](http://codex.wordpress.org/Function_Reference/get_page_by_path)
   
   [Function_Reference/get_page_by_title](http://codex.wordpress.org/Function_Reference/get_page_by_title)
 *  Thread Starter [treelovinhippie](https://wordpress.org/support/users/treelovinhippie/)
 * (@treelovinhippie)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/query_posts-exclude-page/#post-1476242)
 * Awesome, works a treat! … thankyou
 *     ```
       $pagelogo = get_page_by_title('Logo');
       $pageabout = get_page_by_title('About');
       $args=array(
         'post__not_in' => array($pagelogo->ID,$pageabout->ID),
         'post_type' => 'page',
         'post_status' => 'publish',
       );
       ```
   

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

The topic ‘Query_posts exclude page’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [treelovinhippie](https://wordpress.org/support/users/treelovinhippie/)
 * Last activity: [16 years, 1 month ago](https://wordpress.org/support/topic/query_posts-exclude-page/#post-1476242)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
