If you’re not happy with the default number of products per page (16), or if your theme overrides the default WooCommerce setting for “per_page” products and you need to change it, here’s the fix for you.
Please note that you may also need to set the number of WooCommerce product grid columns, so that you can make sure the total number of products per page is a multiple of that and you don’t leave the shop page with empty grid items.
Enjoy!
PHP Snippet: Change “Products per Page” @ WooCommerce Shop
The default number of products per page is 4 rows * 4 columns = 16 products.
Some themes may affect this default setting by using a snippet similar to the one below – in such case try to increase the “9999” priority to a greater number.
In the snippet below, simply define the number of products per page by changing “12” to whatever number you like.
/**
* @snippet 12 Products per Page - WooCommerce Shop
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @compatible WooCommerce 7
* @community https://businessbloomer.com/club/
*/
add_filter( 'loop_shop_per_page', 'bbloomer_redefine_products_per_page', 9999 );
function bbloomer_redefine_products_per_page( $per_page ) {
$per_page = 12;
return $per_page;
}
ah rodolfo, again, you saved my ass from my clients. hahaha.
this code is work like charm.
Nice!
I think it only works if theme supporst Woocommerce:
Which I hope it does in the first place!
Code still works in 2020. Thanks for saving me some developer money.
Great!
excellent
cool
Perfect!
Thanks!
Hello Rodolfo,
I have Multisite, and this snippets does not work. By default Woocomerce shows 12 products, I increased it to 20, but it doesn’t work.
PP Version: 7.3
Wordpress version: .2.2
Woocommerce version: 3.6.5
Update: WordPress 5.2.2
Hi Mario, thanks for your comment! I just tested this again with Storefront theme and it works perfectly. Maybe your theme (or another plugin) is messing/conflicting with my snippet?
To troubleshoot, disable all plugins but WooCommerce and also switch temporarily to “Twentyseventeen” theme (load the snippet there in functions.php) – does it work? If yes, you have a problem with your current theme or one of the plugins.
Hope this helps!
R
Works great! Thank you so much! I don’t know how many snippets I tried before coming across this page to change the amount of products for all pages.
Thanks!
I have tried above snippet and it is no longer working now.
Hi Javed, I just tested this again with Storefront theme and it works perfectly. Maybe your theme (or another plugin) is messing/conflicting with my snippet?
To troubleshoot, disable all plugins but WooCommerce and also switch temporarily to “Twentyseventeen” theme (load the snippet there in functions.php) – does it work? If yes, you have a problem with your current theme or one of the plugins.
Hope this helps!
R
Hi Rodolfo!
I’ve just upgraded my site’s php version to 7.2 and
has been deprecated. Are you prepared to update this snippet to work with 7.2? Would love you even more if you do!! Thanks!
Done ๐
Hey there,
You need to remove the strong html tag around 40 in the code example.
Thanks!
Ben, thank you SO MUCH for your valuable feedback – I just made that correction (I don’t know where the came from lol!). ~R