这是我的代码。
<?php
$meta_query[] = array(
'key' => '_featured',
'value' => 'yes'
);
$args = array(
'post_type' => 'product',
'stock' => 1,
'showposts' => 12,
'orderby' => 'date',
'order' => 'DESC',
'meta_query' => $meta_query
);
?>
在woocommerce 3.0更新之前,这是完美的,但在此之后,这并没有显示正确的产品。
答案 0 :(得分:0)
尝试这样
$args = array(
'post_type' => 'product',
'stock' => 1,
'showposts' => 12,
'orderby' => 'date',
'order' => 'DESC',
'meta_query' => array(
array(
'key' => '_featured',
'value' => 'yes'
)
)
);
答案 1 :(得分:0)
刚刚解决了与此相关的错误。请尝试以下代码:
$args = array(
'post_type' => 'product',
'stock' => 1,
'showposts' => 12,
'orderby' => 'date',
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => 'product_visibility',
'field' => 'name',
'terms' => 'featured',
'operator' => 'IN',
)
)
);