How to Fix the Simultaneous Category and Tag Filter Issue in Elementor Pro Loop

One of the common issues when designing an eCommerce website is the conflict between categories and tags in the Elementor Loop Grid. When designing a “Product Archive Template” and filtering the Loop widget by a specific tag, Elementor encounters a bug and ignores the current category of the page. Consequently, instead of showing only the products within that specific category, it mistakenly lists all products across the entire site that share that tag.
Author:
|
CTO of
Quanta Digital Agency
Published
If you'd like someone to take care of your marketing, I'm here to help, Click Here

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Practical Web Tutorials for WordPress Designers, Developers & SEO Experts on My YouTube Channel
Do you want
 more traffic from Google?

About Peyman Farahani

Peyman Farahani is CTO of Quanta Digital Agency

As a digital problem-solver with a focus on SEO, WordPress, and performance-first design, I’ve helped clients achieve real digital results.

I connect creativity with execution — exploring market gaps, shaping clear ideas, and building solutions that actually make an impact.