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/
Parameter
$query_args (array) — the WP_Query arguments
Quelldatei
index.php
Codebeispiel
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;
});
Verwendungshinweise
- Fügen Sie diesen Code in die
functions.phpDatei Ihres Themes oder in ein benutzerdefiniertes Plugin ein. - Der Hook wird während des Filtervorgangs angewendet — Änderungen werden sofort wirksam.
- Geben Sie stets den erwarteten Wertetyp aus der Callback-Funktion zurück.
