具有和或条件的WordPress分类法查询

我有产品发布类型, 我有product_cat是分类法。在product_cat中, 我有红色, 硬, 软笔整体。
所以我必须让产品变红, 变硬或变软
我怎么能得到这个?
对于红色, 硬性和软性两种产品, 我可以使用以下查询

$args = array( 'post_status' => 'publish', 'posts_per_page' => -1, 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => 'red' ), array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => 'hard' ), array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => 'soft' ) ), 'post_type' => 'product', 'orderby' => 'title', );

但是我需要的是红色, 必须是红色或红色。即(红色& & (软||硬))
请帮忙 。
#1你可以这样尝试:
'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'product_cat', 'field'=> 'slug', 'terms'=> array( 'red' ), ), array( 'relation' => 'OR', array( 'taxonomy' => 'product_cat', 'field'=> 'slug', 'terms'=> array( 'hard' ), ), array( 'taxonomy' => 'product_cat', 'field'=> 'slug', 'terms'=> array( 'soft' ), ), ), ),

未经测试, 但应该可以使用!
如果没有, 这里有一些有用的链接:
https://codex.wordpress.org/Class_Reference/WP_Query
【具有和或条件的WordPress分类法查询】
Mixed relationship taxonomy queries in  WordPress

    推荐阅读