admin管理员组文章数量:1130349
I would improve the search bar in order to exploit manufacture attribute linked to product.
I try to use this to filter product by a custom meta (no product attribute)
function custom_search_query( $query ) {
if ( !is_admin() && $query->is_search ) {
$query->set('meta_query', array(
array(
'key' => 'manufacture',
'value' => $query->query_vars['s'],
'compare' => 'LIKE'
)
));
};
}
add_filter( 'pre_get_posts', 'custom_search_query');
But this puts this condition in AND with standard query, I need to put it in OR.
Any suggestions?
I would improve the search bar in order to exploit manufacture attribute linked to product.
I try to use this to filter product by a custom meta (no product attribute)
function custom_search_query( $query ) {
if ( !is_admin() && $query->is_search ) {
$query->set('meta_query', array(
array(
'key' => 'manufacture',
'value' => $query->query_vars['s'],
'compare' => 'LIKE'
)
));
};
}
add_filter( 'pre_get_posts', 'custom_search_query');
But this puts this condition in AND with standard query, I need to put it in OR.
Any suggestions?
本文标签: wp queryExtend product search with meta in WooCommerce
版权声明:本文标题:wp query - Extend product search with meta in WooCommerce 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749075917a2312303.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论