WordPress – exclude posts from query/loop

June 27th, 2011

If you want to exclude some posts (ID) from your query/loops this is simple solution.

single post with ID #2:

1
query_posts('post__not_in' => array(2));

or more posts (with IDs 5, 7 and 8):

1
query_posts('post__not_in' => array(5, 7, 8));

Comments are closed.