如何使下拉字段的关系使用或逻辑而不是php wordpress
嗨,我目前正在尝试编辑 city 下拉的关系,您可以在此页面在第一个字段 region 上使用或使用逻辑,
我试图更改和通过function.php文件,如下这无效,
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),
);
}
}
谢谢你!
Hi I'm currently trying to edit the relation of the City dropdown which you can find on this page to use the the OR logic like on the first field Region
I have attempted to change the AND to OR through the function.php file like below but this didn't work
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),
);
}
}
Thank you in advance!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须将其更改
为
You have to change this
to