Your example is a bit hard to understand, as it seems to query for meta_values of X,Y,Z,AB,ID,IA
. I hope you can still make sense of the below posted code:
// query posts that have on of the custom values for the custom meta key 'my_key'
// and/or one of the custom meta values for the meta key 'your_key'
$posts = get_posts( array(
'post_type' => 'my_post_type'
,'meta_query' => array(
array(
'key' => 'my_key'
,'value' => array( 'AB', 'ID', 'IA' )
,'compare' => 'IN'
)
,array(
'key' => 'your_key'
,'value' => array( 'AB', 'ID', 'IA' )
,'compare' => 'IN'
)
) );
Other comparison values would be 'LIKE', 'NOT LIKE', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'
where the later twos are reserved for numeric comparison and need an extra meta key/value pair: 'type' => 'numeric'
.