category_name
对于类别分类,sense产品使用product_cat
您需要添加tax_query
进入$args
.
像这样。
$args = array(
\'post_type\' => \'product\',
\'posts_per_page\' => 20,
\'tax_query\' => [
\'taxonomy\' => \'product_cat\',
\'field\' => \'name\',
\'terms\' => \'trofee\',
],
\'meta_query\' => array(
\'relation\' => \'OR\',
array( // Simple products type
\'key\' => \'_sale_price\',
\'value\' => 0,
\'compare\' => \'>\',
\'type\' => \'numeric\'
),
array( // Variable products type
\'key\' => \'_min_variation_sale_price\',
\'value\' => 0,
\'compare\' => \'>\',
\'type\' => \'numeric\'
)
)
);