Query set using tax_query with relation ‘OR’ modifies category object?

The issue is you are overriding the entire tax_query. When you go to the UK category archive, tax query is set to have the same thing you have for International, but you are nuking the current query. Here is the solution:

...
$tax_query = $query->get('tax_query');
$tax_query['relation'] = 'OR';
// puts the item at the beginning of the array instead of the end.
array_unshift( $tax_query, array(
        'taxonomy' => 'category',
        'field' => 'slug',
        'terms' => 'intl',
        'operator' => 'IN'
    );
$query->set( 'tax_query', $tax_query );
...

Leave a Comment