Get posts with multiple meta values
I have a ACF select field which takes multiple value. Now I want to use get_posts()
to get those custom posts. My arguments look like this:
$party = 'test1';
$function = 'test1, test2';
$args = array(
'numberposts' = -1,
'post_type' = 'event',
'meta_query' = array(
'relation' = 'AND',
array(
'key' = 'party',
'compare' = '=',
'value' = $party,
),
array(
'key' = 'function',
'compare' = 'IN',
'value' = array($function),
)
)
);
$items = get_posts($args);
But this does not work! Don't know what is wrong here!
Topic advanced-custom-fields meta-query get-posts Wordpress
Category Web