Hook type: filter
Filters the WP_Query arguments used to count the products for each filter value. Use it to add your own conditions to the product counts, such as excluding a category or a tag.
Parameters
(array)$query_args — the WP_Query arguments of the counts query. They include post_type, post_status, fields (ids), posts_per_page (-1), and the current filters’ tax_query, meta_query and post__in.
Return
array — the modified query arguments. Always return the received array, and keep 'fields' => 'ids'.
Note: the filter runs once for every counted value, so keep the callback fast. The counts are cached, so clear the counts cache after you change the callback.
Example
add_filter( 'awf_product_counts_query', function( $query_args ) {
$query_args['tax_query'][] = array(
'taxonomy' => 'product_tag',
'field' => 'slug',
'terms' => array( 'discontinued' ),
'operator' => 'NOT IN',
);
return $query_args;
} );
The plugin hooks into this filter itself. Adding new keys to the array, as in the example, is safe. Replacing an existing key wholesale, such as tax_query or post__in, would drop the conditions the plugin and the current filters put there.
