i have 5 sets of meta boxes in some custom postype. So.. i know how to compare two meta box values...
Example:
'meta_query' => array(
'relation' => 'AND',
array(
'key' => THEME_PREF.'source_lang_1',
'value' => $sourceLang,
'compare' => '='
),
array(
'key' => THEME_PREF.'target_lang_1',
'value' => $targetLang,
'compare' => '='
),
),
But...
what if i need to check 4 fields - the verification isnt true..
meaning it doesnt returnes only the right results
only "posts" that answer both conditions.
$transargs = array(
'post_type' => 'translators',
'orderby' => 'date',
'order' => 'DESC',
'posts_per_page' => -1,
'meta_query' => array(
'relation' => 'OR',
array(
'relation' => 'AND',
array(
'key' => THEME_PREF.'source_lang_1',
'value' => $sourceLang,
'compare' => '='
),
array(
'key' => THEME_PREF.'target_lang_1',
'value' => $targetLang,
'compare' => '='
)
),
array(
'relation' => 'AND',
array(
'key' => THEME_PREF.'source_lang_2',
'value' => $sourceLang,
'compare' => '='
),
array(
'key' => THEME_PREF.'target_lang_2',
'value' => $targetLang,
'compare' => '='
)
),
)
);
$trns_query = new WP_Query($transargs);
To elaborate
i get a lot of results where the first condition of each meta query is met but not the second one and thus the relation and
Example:
$sourceLang = 1;
$targetLang = 2;
i might also get
(which is not good... the AND doesnt work?)...
result that equals $sourcelang(1) / targetLang(5)