woof_products_query
[ で1回のみ使用woof_products] ショートコード。カスタム操作に必要です。
タームを操作するには、 https://products-filter.com/hook/woof_main_query_tax_relations/
パラメーター
$query_args (array) — WP_Queryの引数
ソースファイル
index.php
コード例
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;
});
使用上の注意
- このコードをテーマの
functions.phpファイルまたはカスタムプラグインに追加してください。 - このフックはフィルタリング処理中に適用され、変更はすぐに反映されます。
- 常にコールバック関数から期待される値の型を返してください。
