我在一些自定义PostType中有5组元框。所以我知道如何比较两个元框值。。。
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...如果我需要检查4个字段怎么办-验证不正确<意味着它不会返回
only the right results只有同时满足这两个条件的“帖子”。
$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我得到了很多结果,其中每个元查询的第一个条件都满足了,但第二个条件没有满足,因此
示例:$sourceLang=1
$targetLang=2;
i might also get<(这不好……和不起作用?)等于$sourcelang(1)/targetLang(5)的结果