[英]How to display four level pages category in WordPress
I have two post types, one is products and another is brands and have a taxonomy product categories. 我有两种职位类型,一种是产品,另一种是品牌,并具有分类产品类别。 How can I get a list of products with specific brand in specific product category
如何获得特定产品类别中具有特定品牌的产品列表
I think something like this should work. 我认为这样的事情应该起作用。
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'include_children' => true
),
),
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'meta_field_name_for_brand',
'value' => 'meta_value_saved_for_product_post',
)
)
);
$products = new WP_Query($args);
if($products->have_posts()) {
while ( $products->have_posts() ) :
$products->the_post();
the_title();
endwhile;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.