woof_products_query
woof_products_query
Мощный фильтр для модификации запроса WP_Query перед получением товаров. Используется для добавления своих условий, мета-запросов и т.д.
Parameters
$query_args (array) — аргументы WP_Query
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.phpfile 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.