【发布时间】:2018-10-04 18:57:23
【问题描述】:
我有 product 帖子类型,我有 product_cat 是分类法。在 product_cat 我有 red, hard, soft, pen 整体。
所以我必须让产品变红,变硬或变软
我怎样才能得到这个?
对于同时属于红色和硬性和软性的产品,我可以使用以下查询
$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',
);
但我需要的是红色是必须的,无论是软的还是硬的。
即(red && (soft||hard ))
请帮忙。
【问题讨论】:
标签: wordpress wordpress-theming taxonomy-terms