![](/img/trans.png)
[英]Sort specific Woocommerce product variations by menu_order in a WP_Query
[英]How do i make a WP_Query to get product variations with specific attribute key and attribute value?
如何制作WP_Query以獲取具有特定屬性鍵和屬性值的WC_Product_Variation?
我所知道的是如何獲得WC_Product
$all_products_query = new WP_Query( array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => '-1',
) );
您可以使用meta_query
參考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 );
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.