查询同一键的多个值

时间:2015-12-12 作者:Abdulrahman Khaled

我试着得到两个不同的帖子,其中的值$al. 我可以一次检索一个帖子,但无法同时检索到这两个帖子:

$al = array(\'51.66963\',\'51.60652\');

$meta_query[] =  array(
  \'meta_query\' => array(
   \'relation\'  => \'AND\',
    array(
        \'key\'     => \'estate_property_google_maps\',
        \'value\'   => $al[\'0\'],
        \'compare\' => \'LIKE\',
    ),
),
  array(
      \'key\'       => \'estate_property_google_maps\',
      \'value\'       => $al[\'1\'],
      \'compare\'       => \'LIKE\',
      ),
);

1 个回复
最合适的回答,由SO网友:montrealist 整理而成

难道不是这样吗(doc)?

$meta_query[] = array( \'meta_query\' => array(
    \'relation\' => \'AND\',
    array(
        \'key\'     => \'estate_property_google_maps\',
        \'value\'   => $al[\'0\'],
        \'compare\' => \'LIKE\'
    ),
    array(
      \'key\'       => \'estate_property_google_maps\',
      \'value\'       => $al[\'1\'],
      \'compare\'       => \'LIKE\'
    ),
) );

相关推荐