meta_query compare='!=' with multiple custom fields
-
Hi everyone,
a post has the following custom fields:
'my_custom_field' => 1 'my_custom_field' => 2 'my_custom_field' => 3
I now want to query all posts that do NOT contain the value 2 for ‘my_custom_field’. I’m trying this:
$args = Array('posts_per_page' => -1, 'post_type' => 'page', 'meta_query' => array( array( 'key' => 'my_custom_field', 'value' => 2, 'compare' => '!=' ) ) );
However, this is still returning my sample post, as my sample post has a field of ‘my_custom_field’ with a value other than 2 (1 and 3). I somehow need to change my query to say “Exclude posts that have at least one field of ‘my_custom_field’ with the value of 2”.
Can anyone help me? Thanks!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘meta_query compare='!=' with multiple custom fields’ is closed to new replies.