php中get_featured_posts()是什么意思,php – 在WP_Query中获取WooCommerce特色产品
自Woocommerce 3以來,您需要使用Tax Query,因為特色產品現在由product_visibility自定義分類法處理,用于以下術語:
// The tax query
$tax_query[] = array(
'taxonomy' => 'product_visibility',
'field' => 'name',
'terms' => 'featured',
'operator' => 'IN', // or 'NOT IN' to exclude feature products
);
// The query
$query = new WP_Query( array(
'post_type' => 'product',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'posts_per_page' => $products,
'orderby' => $orderby,
'order' => $order == 'asc' ? 'asc' : 'desc',
'tax_query' => $tax_query // <===
) );
參考文獻:
You could use 07002 to get the featured product IDs array but using a tax query in a WP_Query is just fine and the right way…
有關:
它應該有效.
總結
以上是生活随笔為你收集整理的php中get_featured_posts()是什么意思,php – 在WP_Query中获取WooCommerce特色产品的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 3正确使用配置电控燃油喷射发动机的车辆?
- 下一篇: python自动化部署程序,聊聊Pyth