admin管理员组文章数量:1130349
I need to modify the WooCommerce product query because I want to filter the shown products on the shop pages based on the taxonomies for each product. So what I've tried is this here:
add_filter( 'woocommerce_product_query_meta_query', 'filter', 10, 2 );
function filter( $meta_query, $query ) {
// Only on category pages
if ( ! is_product_category() ) {
return $meta_query;
}
$tags_array[] = 'ABCSD';
$meta_query[] = array(
'key' => 'product_tag',
'value' => $tags_array,
'compare' => 'EXIST'
);
return $meta_query;
}
So I just want to display all products which have the taxonomy ABCSD in it. The code is placed in my functions.php. What I'm doing wrong here?
I need to modify the WooCommerce product query because I want to filter the shown products on the shop pages based on the taxonomies for each product. So what I've tried is this here:
add_filter( 'woocommerce_product_query_meta_query', 'filter', 10, 2 );
function filter( $meta_query, $query ) {
// Only on category pages
if ( ! is_product_category() ) {
return $meta_query;
}
$tags_array[] = 'ABCSD';
$meta_query[] = array(
'key' => 'product_tag',
'value' => $tags_array,
'compare' => 'EXIST'
);
return $meta_query;
}
So I just want to display all products which have the taxonomy ABCSD in it. The code is placed in my functions.php. What I'm doing wrong here?
本文标签: phpWooCommerce get products based on the taxonomy
版权声明:本文标题:php - WooCommerce get products based on the taxonomy 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749122333a2319212.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论