带有分类筛选器的自定义类别页

时间:2018-03-30 作者:user2821847

从URL筛选的Wordpress自定义类别页面。

我有两种分类法-offer和network

在“自定义类别”页面“加载”上未显示任何内容。即使我使用或和。

当我过滤时,有时会得到正确的显示。

我认为问题出在else语句中。有人能看到问题吗?我做错了什么?

if (isset($_GET[\'offer\']) && !empty($_GET[\'offer\']))
    {
        $offer = $_GET[\'offer\'];
    }

    else
    {
                    **$offer = \'\';**
    }


if (isset($_GET[\'network\']) && !empty($_GET[\'network\']))
    {
        $network = $_GET[\'network\'];
    }
    else
    {
                    $network = \'\';
    }


\'tax_query\' => array(

    \'relation\' => \'OR\',

  array(
    \'taxonomy\' => \'offer\',
    \'field\' => \'slug\',
    \'terms\' => $offer,
    \'operator\' => \'IN\'
  ),

  array(
    \'taxonomy\' => \'network\',
    \'field\' => \'slug\',
    \'terms\' => $network,
    \'operator\' => \'IN\'
  ),

),

1 个回复
SO网友:user2821847

解决方案:在tax\\u查询中添加“operator”=>“AND”。

\'tax_query\' => array(

\'relation\' => \'OR\',

array(

    \'taxonomy\' => \'offer\',
    \'field\' => \'slug\',
    \'terms\' => array($offer),
      \'operator\' => \'AND\',
),

array(

    \'taxonomy\' => \'network\',
    \'field\' => \'slug\',
    \'terms\' => array($network),
      \'operator\' => \'AND\',
),

结束