你好,我正在尝试编辑城市的关系下拉列表,你可以在这个页面上找到,使用OR逻辑,就像在第一个字段区域
我试图通过下面的function.php文件将AND更改为OR,但这不起作用
function filter_florida_location() {
ob_start();
$tax_query = array('relation' => 'AND');
if (isset($_POST['region']) && !empty($_POST['region']))
{
$tax_query[] = array(
'taxonomy' => 'region',
'field' => 'term_id',
'terms' => $_POST['region'],
//'operator' => 'IN',
);
}
if (isset($_POST['city']) && !empty($_POST['city']))
{
foreach($_POST['city'] as $key => $val){
$tax_query[] = array('relation' => 'OR');
$tax_query[][] = array(
'taxonomy' => 'city',
'field' => 'term_id',
'terms' => array($val),
);
}
}
提前感谢!!
你必须改变这个
$tax_query[] = array('relation' => 'OR');
$tax_query['relation'] = 'OR';