Woocommerce - Display Featured Products at top of Category Page

前端 未结 2 1641
一向
一向 2020-12-21 21:59

I want to have a section at the top of each product category page that shows three featured products at random from that category. Beneath this would be the regular archive

2条回答
  •  攒了一身酷
    2020-12-21 22:35

    I made a note on displaying featured products by category and created a simple plugin with a shortcode. See full notes here https://jameshwartlopez.com/plugin/get-featured-products-of-a-category/.

    Basically you just need to download and install the plugin I created https://github.com/jameshwartlopez/jvl-featured-product-by-category

    Then in your functions.php file, you either hook to woocommerce_before_shop_loop or woocommerce_archive_description. Test which hook looks okay for your site. Below is an example.

    slug
            echo do_shortcode( "[featured_products_by_category cat='".$cat_slug."']" );
        }
    
    });
    

提交回复
热议问题