-
-
Save woogists/e414d9463d8843bbe4efc4c4c519d888 to your computer and use it in GitHub Desktop.
/** | |
* Change number of products that are displayed per page (shop page) | |
*/ | |
add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 ); | |
function new_loop_shop_per_page( $cols ) { | |
// $cols contains the current number of products per page based on the value stored on Options -> Reading | |
// Return the number of products you wanna show per page. | |
$cols = 9; | |
return $cols; | |
} |
I have the same problem... :(
same problem
Guys, in Divi, this snippet doesn't work, however you can easily change the number of products in the Divi Theme options on the General Tab.
@cesarguillenf
Try Divi Theme Options =>
Number of Products displayed on WooCommerce archive pages
Thank you very much. I've changed the product number per page in the Divi Theme Options and it works fine.
hello, how i can use that for display product at mobile? 4 mobile 5 desktop ?¿
ty
The description of this snippet in the original woocommerce docs is simply WRONG.
$cols DOES NOT decide the number of products, it decides the NUMBER OF COLUMNS in which the products are displayed.
Why do you think it's called $COLS, not $nproducts or similar ? Because it's about the NUMBER OF COLUMNS !
So this here:
https://woocommerce.com/document/change-number-of-products-displayed-per-page/
should be changed to read something like:
/**
- Change number of COLUMNS for displaying the products (shop page)
*/
add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );
function new_loop_shop_per_page( $cols ) {
// $cols contains the current number of COLUMNS in which the number of products based on the value stored on Options –> Reading is displayed , so let's say you have 9 posts in Reading settings, and 3 as $cols here, that will display 9 products in 3 rows of 3 products each !
// Return the number of COLUMNS PER ROW you wanna show ON THE SHOP PAGE
$cols = 3;
return $cols;
If I use $cols = 12; instead of $cols = 9;.
Why It's not working in my WordPress Divi theme ??