我已经绞尽脑汁思考了太久,但找不到解决方案,我尝试过使用插件来连接 woo 商务文档和店面文档,但没有成功。
默认情况下,主题有“新品”和“畅销商品”,其中列出了 4 个“新品”和 4 个“畅销商品”
我想将 4 个“新产品”增加到 8 个,即 2 行 4 列,并将“畅销产品”更新为随机,以便显示不同的产品
我怎样才能实现这个目标?
例子:https://etzeo.com/
以下内容会将“新品”部分的产品从 4 种增加到 8 种(分四列),并在店面主页上以随机顺序显示“畅销品”:
// "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;
}
代码位于活动子主题(或活动主题)的 function.php 文件中。经过测试并有效。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)