Woocommerce:显示按属性过滤的产品 [英] Woocommerce: Show products filtered by attribute

查看:25
本文介绍了Woocommerce:显示按属性过滤的产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用复选框或链接在 Woocommerce 中按属性过滤产品.如果我选中复选框或单击链接,我希望获得具有此属性的所有产品.

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?

现在我需要进行查询以获取在我的案例中具有自定义属性演示"的所有产品.

Now i need do a query to get all products that have a custom attribute 'demo' in my case.

我正在这样做:

$args = array ( 'meta_query' => array( 
array( 'key' => 'meta_value', 
       'value' => 'demo', 
       'compare' => 'LIKE', ), 
       ), 
);

怎么了??

谢谢!

推荐答案

好的,我终于知道结果了!

Ok i got finally the result!

我有这个:

$args = array ( 
     'post_type'  => 'product',
     'posts_per_page'  => 12,
     'meta_query' => array( 
         array( 
          'value' => 'demo', 
          'compare' => 'like'
         ), 
       ), 

);

无论如何感谢您的帮助!

Thanks anyway for the help!

这篇关于Woocommerce:显示按属性过滤的产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆