如何使WP_Query获取具有特定属性键和属性值的产品变体?

时间:2017-02-07 08:57:44

标签: php wordpress woocommerce

如何使WP_Query获取具有特定属性键和属性值的WC_Product_Variation?

我所知道的是如何获得WC_Product

$all_products_query = new WP_Query( array(
'post_type'         => 'product',
'post_status'       => 'publish',
'posts_per_page'    => '-1',
) );

1 个答案:

答案 0 :(得分:1)

您可以使用meta_query --refer https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters

     $args = array(
         'post_type' => 'product',
         'meta_key' => 'key',
         'meta_value' => 'value'
      );
     $query = new WP_Query( $args );
相关问题