black_belt black_belt - 1 year ago 80
PHP Question

WHERE NOT Query in Wordpress

I am querying into database using the following code and it is working fine

<?php query_posts(


); ?>

Could you please tell me how to add WHERE NOT with the above query.

WHERE ID != '400' AND ID!='401'

Answer Source

In wordpress query post add argument post__not_in.

'post__not_in' => array(400, 401)

$args = array(
     'post_type' => 'gallery',
     'posts_per_page' => $gnum,
     'post__not_in' => array(400, 401),
     'paged' => $paged,
     'orderby' => 'title',
     'order' => 'ASC'

So your query post will be like,

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download