• I’m trying to use query_posts to fetch posts, excluding those with custom field values that are in a provided array.

    Here is the meta_query part of query_posts that I am using:

    array( array( 'key' => 'special', 'value' => array( 'val1', 'val2', 'val3' ), 'compare' => 'NOT IN' ) )

    To clarify, I want to fetch all posts, except those that have val1, val2 and/or val3 as ‘special’ meta values. In theory this meta_query code work, but it is still fetching posts that have the specified meta values.

    Would really appreciate any insight into why this isn’t working!

    Thanks!!

Viewing 1 replies (of 1 total)
  • What about:

    $args = array(
    	'meta_query' => array(
    		array(
    			'key' => 'special',
    			'value' => 'val1',
    			'compare' => 'NOT LIKE'
    		),
    		array(
    			'key' => 'special',
    			'value' => 'val2',
    			'compare' => 'NOT LIKE'
    		),
    		array(
    			'key' => 'special',
    			'value' => 'val3',
    			'compare' => 'NOT LIKE'
    		)
    	)
     );
Viewing 1 replies (of 1 total)
  • The topic ‘meta_query using NOT IN’ is closed to new replies.