我对下面的代码有问题。试图对存储在mls post类型中的post中的元数据进行查询。我想我知道问题是什么,但不知道如何解决。我猜这与存储为字符串的值有关。我搜索了一下,发现其他人对此感到困惑,但没有找到解决方案。这里有两个我尝试过但运气不佳的例子。
<?php $args = array(
\'post_type\' => \'mls\',
\'meta_query\' => array(
relation => \'AND\',
array(
\'key\' => \'_city\',
\'value\' => \'Clarkson\',
\'compare\' => \'=\'
),
array(
\'key\' => \'_price\',
\'value\' => \'200000\',
\'type\' => \'numeric\',
\'compare\' => \'>=\'
)
//array(
// \'key\' => \'_price\',
// \'value\' => array( 200000, 1000000 ),
// \'type\' => \'numeric\',
// \'compare\' => \'BETWEEN\'
//)
)
); ?>
SO网友:Dameer
也许我错了,但您缺少查询关系。。。
<?php $args = array(
\'post_type\' => \'mls\',
\'meta_query\' => array(
relation => \'AND\',
array(
\'key\' => \'_city\',
\'value\' => \'Clarkson\',
\'compare\' => \'=\'
),
array(
\'key\' => \'_price\',
\'value\' => \'200000\',
\'type\' => \'numeric\',
\'compare\' => \'>=\'
)
//array(
// \'key\' => \'_price\',
// \'value\' => array( 200000, 1000000 ),
// \'type\' => \'numeric\',
// \'compare\' => \'BETWEEN\'
//)
)
); ?>