view raw
black_belt black_belt - 6 months ago 46
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'


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,