I need for a project to sort via a php variable the entire product list by a specific variation of a custom attribute, I am having trouble listing products that have a specific variation, i have tried multiple statements with meta_query or tax_query similar to:
add_filter('woocommerce_ordering_args', 'custom_woocommerce_ordering_args');
function custom_woocommerce_ordering_args( $args ) {
$args = array(
'post_type' => 'product',
'meta_query' => array(
array(
'key' => 'pa_attribute',
'value' => 'attribute_value',
'compare' => '=',
)
)
);
$query = new WP_Query( $args );
}
Where attribute is the variable attribute I have set, and the attribute_value is the value I am searching for.
It seems to do nothing to the product query.
Thank you in advance!