HUSKY - Product Filter for WooCommerce

woof_products_query

Using only 1 time in [woof_products] shortcode. Needs for any custom manipulations.


For manipulations with taxonomies use https://products-filter.com/hook/woof_main_query_tax_relations/

Parameters

$query_args (array) — the WP_Query arguments

Source File

index.php

Code Example


add_filter('woof_products_query', function($query_args) {
    // Exclude products with specific meta key
    $query_args['meta_query'][] = array(
        'key'     => '_exclude_from_filter',
        'compare' => 'NOT EXISTS'
    );
    
    // Only show products from specific categories
    // $query_args['tax_query'][] = array(
    //     'taxonomy' => 'product_cat',
    //     'field'    => 'slug',
    //     'terms'    => array('featured'),
    //     'operator' => 'IN'
    // );
    
    return $query_args;
});

Usage Notes

  • Add this code to your theme's functions.php file or a custom plugin.
  • The hook is applied during the filtering process — changes take effect immediately.
  • Always return the expected value type from the callback function.