I wondered how I could exclude posts in WordPress.
E.g. I have a string
$exclude_ids (= "4,5,6") or (="-4,-5,-6")
and I would like to prevent these posts from showing up. How would I do that?
I already tried:
query_posts('p=' . $exclude_ids);
but that didn’t really work out and I didn’t really find any information regarding this topic on google.
Cheers
Here’s the relevant info from the docs:
It’s in the Codex: http://codex.wordpress.org/Function_Reference/query_posts
use the
post__not_in
, something like:query_posts(array('post__not_in'=>'1,2,3'))
The ideal solution would be to create a category, add those posts to it, then exclude the category. But if you really want to single out posts, it could be done as follows:
Just use that if statement in your Loop. The continue will skip over that iteration for any of the listed posts.
Source: http://www.sandboxdev.com/blog/wordpress/180/exclude-single-post/