View Categories

WooCommerce:更改相关产品数

< 1 min read

仿牌独立站出海专家
Snippet(PHP):更改相关产品数量(行和列)– WooCommerce


add_filter( 'woocommerce_output_related_products_args', 'bbloomer_change_number_related_products', 9999 );
 
function bbloomer_change_number_related_products( $args ) {
 $args['posts_per_page'] = 4; // # of related products
 $args['columns'] = 4; // # of columns per row
 return $args;
}

将相关产品的数量更改为4


@media (min-width: 768px) {
.site-main .related.products ul.products li.product {
    width: 22%;
    float: left;
    margin-right: 4%;
}
}