WooCommerce WP_Query using tax_query returns no results (0 = 1)

Question

I am trying to get specific Products from WooCommerce baseed on a Product Attribute (taxonomy).

$args = array(
            'post_type' => array('product', 'product_variation'),
            'post_status' => 'publish',
            'tax_query' => array(
                 array(
                       'taxonomy'         => 'pa_range-kwh',
                       'terms'            => 'k2',
                       'field'            => 'slug',
                       'operator'         => 'IN',
                       'include_children' => true,
                        ),
            
            ),
    
    
        );

From an SQL point of view
I can see that:

SELECT * FROM `wp_terms` WHERE term_id = 891

returns

wp_terms

SELECT * FROM `wp_term_taxonomy` where term_id = 891

returns
enter image description here

SELECT * FROM `wp_term_relationships` where term_taxonomy_id = 891

returns

wp_term_relationships

Although there is at least one product where the taxonomy is added, I keep on receiving 0 results due to the inner query returning (0 = 1), meaning it can’t find any product with this taxonomy attributed.

Any ideas on what could I do to overcome this?

0
, , kernel52 1 year 2020-07-26T07:10:26-05:00 0 Answers 52 views 0

Leave an answer

Browse
Browse