Customize displayed products on Woocommerce Storefront home page

前端 未结 1 1420
别那么骄傲
别那么骄傲 2021-01-14 21:41

I have been rattling my brain over this far too long and I cannot find the solution, I have attempted plugins, to the woo commerce documentation and the storefront documenta

相关标签:
1条回答
  • 2021-01-14 22:06

    The following will increase products from 4 to 8 (on four columns) for "New In" section and display "Best Sellers" to a random order on Storefront Home page:

    // "New In" Home products section
    add_filter( 'storefront_recent_products_args', 'filter_storefront_recent_products_args', 10, 1 ); 
    function filter_storefront_recent_products_args( $args ) {
        $args['limit'] = 8;
        $args['columns'] = 4;
    
        return $args;
    }
    
    // "Best Sellers" Home products section
    add_filter( 'storefront_best_selling_products_args', 'filter_storefront_best_selling_products_args', 10, 1 ); 
    function filter_storefront_best_selling_products_args( $args ) {
        $args['orderby'] = 'rand'; // Random
    
        return $args;
    }
    

    Code goes in function.php file of your active child theme (or active theme). Tested and works.

    0 讨论(0)
提交回复
热议问题