I want to filter products by attribute in Woocommerce using a checkbox or alternatively a link. If I mark the checkbox or click the link I want get all products that have this attribute.
How can I do this? Which files should I edit?
Edit: Now i need do a query to get all products that have a custom attribute 'demo' in my case.
I'm doing this:
$args = array ( 'meta_query' => array(
array( 'key' => 'meta_value',
'value' => 'demo',
'compare' => 'LIKE', ),
),
);
Whats wrong??
Thanks!
答案 0 :(得分:0)
好的,我终于得到了结果!
我有这个:
$args = array (
'post_type' => 'product',
'posts_per_page' => 12,
'meta_query' => array(
array(
'value' => 'demo',
'compare' => 'like'
),
),
);
无论如何,谢谢你的帮助!