HUSKY - Product Filter for WooCommerce

woof_products_query

Yalnızca 1 kez [woof_products] kısa kodu. Herhangi bir özel işlem için gereklidir.


Taksonomilerle işlem yapmak için https://products-filter.com/hook/woof_main_query_tax_relations/

Parametreler

$query_args (array) — WP_Query argümanları

Kaynak Dosya

index.php

Kod Örneği


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;
});

Kullanım Notları

  • Bu kodu temanızın functions.php dosyasına veya özel bir eklentiye ekleyin.
  • Kanca, filtreleme işlemi sırasında uygulanır — değişiklikler hemen yürürlüğe girer.
  • Geri arama işlevinden her zaman beklenen değer türünü döndürün.