我正在尝试创建一个WP\\u查询,其结果参数如下:
$args = array(
\'post_type\' => array( \'post\', \'custom\' ),
\'meta_query\' => array(
\'relation\' => \'AND\',
array(\'key\' => \'key1\', \'value\' => \'value1\'),
array(\'key\' => \'key2\', \'value\' => \'value2\'),
array(\'key\' => \'key3\', \'value\' => \'value3\')
)
);
我真正要做的是创建一个高级搜索,它可以让元值像这样搜索:
//$queryData = array();
//parse_str($_SERVER[\'QUERY_STRING\'], $queryData);
$queryData = array(\'key1\' => \'value1\',\'key2\' => \'value2\',\'key3\' => \'value3\');
$args = array(
\'post_type\' => array( \'post\', \'custom\' ),
\'meta_query\' => array(
\'relation\' => \'AND\',
/* ADD $queryData loop HERE*/
)
);
我试图避免手动创建每个搜索参数:
array(\'key\' => \'key1\', \'value\' => \'value1\'),
array(\'key\' => \'key2\', \'value\' => \'value2\'),
array(\'key\' => \'key3\', \'value\' => \'value3\')
只需使用$\\u SERVER[\'QUERY\\u STRING\']创建数组并循环,将数组添加到meta\\u QUERY
我很难将数组合并或添加到meta\\u查询