How to Use WordPress Query_posts and Exclude a Page

Excluding pages from the WordPress query_posts loop is easy. You can exclude a page by its ID, Slug or Title. See the example below to get an idea how the WordPress query_posts function can work for you!

How to Use WordPress Query_posts and Exclude a Page

Exclude a Page by ID

//replace the 3,8 with your page ids

Will the Full WordPress Loop

Here’s an example of how you can use the WordPress query_posts function to query all pages except those in your ID array:

 
	
    
<?php get_post_meta($post->ID, 'associate-thumb-alt', true); ?> no thumb

 

 

View Profile

 

 

Exclude a Page by Title Rather Than ID

You may want to exclude a page by it’s title rather than an ID. Here we will use two WordPress functions:

	



Notice how we are assigning the $exclude1 and $exclude2 variables and then grabbing the IDs from those page titles and putting them into the post_not_in array.

Original Thread

Leave a Reply

Your email address will not be published. Required fields are marked *