Query posts without a specific ID

How would we query posts as long as the post does not equal the ID 2047?

Here is the current query.

<?php 
$args1 = array(
    'post_type' => 'options',
    'tag_slug__and' => array( $triplevel, $divingtrip, 'accommodation' ),
    'posts_per_page' => -1,
    'offset' => 1,
); 
query_posts( $args1 ); while (have_posts()) : the_post();
?>

I tried this…

query_posts( $args1 . 'p!=2047' );

..to no effect.

Any ideas?

Marvellous

1 Answer
1

Most of the things you can do with a query are described in the Codex page for WP_Query

You need to use the ‘post__not_in’ parameter eg:

$args = array(    
              'post__not_in' => array('34','54'), // post ids   
              'post_type' => 'page'   
             );` 

Leave a Comment