WP_Query with meta_query
I’m trying to list post with different custom fields
my args looks like this:
$args = array( 'post_type' => 'post', 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'ACF_type', 'value' => $t, 'compare' => 'LIKE' ), array( 'key' => 'ACF_sex', 'value' => $s, 'compare' => 'LIKE' ) ) );
And that works but I realy whant to use ‘compare’ => ‘=’ but when change to this no post are listed
I’ve tried with string,char and numeric but nothing shows when I use ‘=’
What am I doing wrong?
That’s strange. And when you remove ‘compare’ from the array? The default value is ‘=’, so you don’t really need it. Try also with this
'relation' => 'OR'
Yes I think it’s strange
I’ve tried to use OR and then I get more hits but I whant to use AND to only show post with the both values
I’m using Advanced Custom Fields plugin to add this different custom fields but that schould not be the problem because I can use the custom fields like normal fields
- The topic ‘WP_Query with meta_query’ is closed to new replies.