To solve this limitation, you don’t need to install heavy or extra plugins. By using a WordPress filter, we can force Elementor to create an exact intersection between the “selected tag” and the “current category”.
Simply copy the code snippet below and place it in your Child Theme’s functions.php file. If you don’t have access to your theme files, you can use plugins like Code Snippets to run this code in your site’s backend.
// Fix WordPress bug: Apply tag and category conditions simultaneously in Elementor Loop
add_filter( 'woocommerce_shortcode_products_query', function( $query_args, $atts, $loop_name ) {
if ( is_product_category() ) {
$current_cat = get_queried_object();
$has_tag = false;
if ( isset( $query_args['tax_query'] ) ) {
foreach ( $query_args['tax_query'] as $tax ) {
if ( isset( $tax['taxonomy'] ) && $tax['taxonomy'] === 'product_tag' ) {
$has_tag = true;
break;
}
}
}
if ( $has_tag ) {
$query_args['tax_query'][] = [
'taxonomy' => 'product_cat',
'field' => 'term_id',
'terms' => $current_cat->term_id,
'include_children' => true,
];
$query_args['tax_query']['relation'] = 'AND';
}
}
return $query_args;
}, 10, 3 );
The Technical Reason Behind the Category and Tag Conflict in Elementor
In the architecture of Elementor Pro’s query builder, the base WP_Query class in WordPress is used for displaying product grids. When you design an Archive Template, the Elementor widget relies on reading the Current Query to understand which page the user is currently on.
The conflict bug occurs when you apply a supplementary filter (like selecting a Product Tag) in the Loop Grid widget settings:
- Context Loss: As soon as Elementor receives the manual tag filter, it completely ignores the default query of the archive page and replaces it with a Custom Query. Because of this, the system forgets which category the user is currently browsing.
- Lack of Automatic Taxonomy Integration: By default, Elementor doesn’t have a mechanism to simultaneously combine archive filters (product_cat) and custom widget filters (product_tag) in loop mode, effectively overriding the former with the latter.
How Does the Code Above Fix This Elementor Issue?
This code snippet intervenes exactly before Elementor fetches product information from the database. First, the system intelligently detects which site category the user is currently viewing.
Then, instead of Elementor’s binary behavior, it sends a mandatory command to the WordPress core to create a “conditional intersection.” Simply put, it forces WordPress to check both filters simultaneously. As a result, the archive page will only display products that both contain the selected tag and belong exactly to the user’s current category.