WooCommerce: Change Number of Products Per Page

If you have many products and don’t want to use pagination (splitting the page in 1, 2, 3 or more pages), here’s the fix for you.

Edit the number of WooCommerce products per page (12 in this case)

PHP Snippet: Change “Products per Page” @ Shop and Loop Pages

The default number of products per page is 4 rows * 4 columns = 16 products.

Some themes may affect this default figure:

  • by using a snippet similar to the one below
  • or by following the settings defined at WordPress Dashboard > Reading > “Blog pages show at most”.

In the snippet below, simply define the number of products per page by changing “12” to whatever number you like.

/**
 * @snippet       Products per Page - WooCommerce Shop
 * @how-to        Watch tutorial @ https://businessbloomer.com/?p=19055
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.6.2
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

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;
}

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (before "?>" if you have it). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7+.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce Customization?

Check out these free video tutorials!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP

Rodolfo Melogli

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as a WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

8 thoughts on “WooCommerce: Change Number of Products Per Page

  1. 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.

    1. Thanks!

  2. I have tried above snippet and it is no longer working now.

    1. 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

  3. Hi Rodolfo!

    I’ve just upgraded my site’s php version to 7.2 and

    create_function()

    has been deprecated. Are you prepared to update this snippet to work with 7.2? Would love you even more if you do!! Thanks!

    1. Done ๐Ÿ™‚

  4. Hey there,

    You need to remove the strong html tag around 40 in the code example.

    Thanks!

    1. Ben, thank you SO MUCH for your valuable feedback – I just made that correction (I don’t know where the came from lol!). ~R

Questions? Feedback? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between: [php]code_here[/php]. Failure to complying with this (as well as going off topic) will result in comment deletion. You should expect a reply in about a week - this is a popular blog but I need to get paid work done first. Please consider joining #BloomerArmada to ask me 1-to-1 WooCommerce questions. Thank you :)

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.