在Woocommerce店面主页上自定义显示的产品 [英] Customize displayed products on Woocommerce Storefront home page
问题描述
我已经花了很长时间思考了一下,但我一直无法找到解决方案,我尝试了woo商务文档和店面文档的插件,但是没有成功.
默认情况下,该主题具有新建"和畅销书",其中列出了4个新建"和4个畅销书"
我想将4个新商品"增加到8个,这样2行4列,并将畅销商品"更新为随机商品,以便显示不同的商品
我该如何实现?
代码进入您的活动子主题(或活动主题)的function.php文件中.经过测试,可以正常工作.
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 documentation but no success.
The theme by default had a "New In" and "Best Sellers" where it listed 4 "New In" and 4 "Best Sellers"
I want to increase the 4 "New In" to 8 so 2 rows of 4 columns and update the "Best Sellers" to a Random so different products show
How can I achieve this?
Example: https://etzeo.com/
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.
这篇关于在Woocommerce店面主页上自定义显示的产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!