我有以下疑问,$the_query = new WP_Query( $args );
, 它应该显示H\\u property\\u类型的任何属性bandb, hotel 或dining.
如果我打印$args,我会得到以下结果,我希望效果很好:
Array(
[post_type] => property
[posts_per_page] => -1
[orderby] => H_featured
[order] => DESC
[meta_query] => Array
(
[relation] => OR
[0] => Array
(
[key] => H_property_type
[value] => bandb
[compare] => on
)
[1] => Array
(
[key] => H_property_type
[value] => hotel
[compare] => on
)
[2] => Array
(
[key] => H_property_type
[value] => dining
[compare] => on
)
)
)
但出于某种原因,此技术仅检索其中一个复选框的结果,即它们都具有H\\U property\\U类型的酒店。
我做错了什么?
我的参数是使用以下代码设置的:
if(isset($_GET[\'H_property_type\'])){
if(count($_GET[\'H_property_type\']) > 1){
$args[\'meta_query\'][\'relation\'] = \'OR\';
}
foreach ($_GET[\'H_property_type\'] as $type) {
$args[\'meta_query\'][] = array(
\'key\' => \'H_property_type\',
\'value\' => $type,
\'compare\' => \'on\'
);
}
}