答案 0 :(得分:0)
检查以下代码:
[product_category category="products" orderby="_featured" order="DESC"]
或者您可以通过在现有查询中添加meta_key ='__featured'和orderby ='meta_value_num'来尝试自定义查询
答案 1 :(得分:0)
适合寻求解决方案的人。您可以使用https://wordpress.org/plugins/featured-products-by-category/并使用提供的简码。
在活动主题函数中添加以下代码。php
<?php
/*
Show featured products first. Before the normal product list
*/
add_action('woocommerce_before_shop_loop', function() {
if(is_product_category()) {
$current_term = get_queried_object();
echo do_shortcode('[featured_products_by_category cat="'.$current_term->slug.'" limit=3]');
}
});
查看完整的帖子here:https://jameshwartlopez.com/plugin/show-featured-products-in-product-category-pages/