0

Wordpress custom category page that filters from URL.

I have two taxonomies - offer and network

On custom category page load nothing appears. Even when I use OR or AND.

When I filter I sometime get the correct display.

I believe the problem is in the else statement. Can anyone see the problem? WHat am I doing wrong?

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'
  ),

),
  • Could you post some bigger part of your code? It's hard to say what this code will look like, since you cut it in such way, that it's even not a correct code anymore ;) – Krzysiek Dróżdż Mar 30 '18 at 16:26
0

The solution: Add 'operator' => 'AND', to the tax_query.

'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',
),

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.