WooCommerce: Change Number of Products Per Page

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!

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

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

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

  • WooCommerce: Disable Variable Product Price Range $$$-$$$
    You may want to disable the WooCommerce variable product price range which usually looks like $100-$999 when variations have different prices (min $100 and max $999 in this case). With this snippet you will be able to hide the highest price, and add a “From: ” prefix in front of the minimum price. At the […]
  • WooCommerce: Hide Price & Add to Cart for Logged Out Users
    You may want to force users to login in order to see prices and add products to cart. That means you must hide add to cart buttons and prices on the Shop and Single Product pages when a user is logged out. All you need is pasting the following code in your functions.php (please note: […]
  • WooCommerce Visual Hook Guide: Archive / Shop / Cat Pages
    I’ve created a visual HTML hook guide for the WooCommerce Archive Page (which is the same page for the Shop, Category, Tag pages). This visual guide belongs to my “Visual Hook Guide Series“, that I’ve put together so that you can find WooCommerce hooks quickly and easily by seeing their actual locations (and you can […]
  • WooCommerce: Hide Prices on the Shop & Category Pages
    Interesting WooCommerce customization here. A client of mine asked me to hide/remove prices from the shop page and category pages as she wanted to drive more customers to the single product pages (i.e. increasing the click-through rate). As usual, a simple PHP snippet does the trick. I never recommend to use CSS to “hide” prices, […]
  • WooCommerce: How to Remove the “Default Sorting” Dropdown
    If the WooCommerce product sorting functionality (“Default Sorting” dropdown) is a waste of space or you don’t need that select box at all, you may want to remove it. No matter if you prefer custom code or a simple plugin – hiding the product sorting dropdown is a piece of cake. Enjoy!

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent 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. Follow @rmelogli

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

  1. ah rodolfo, again, you saved my ass from my clients. hahaha.
    this code is work like charm.

    1. Nice!

  2. I think it only works if theme supporst Woocommerce:

    add_theme_support( 'woocommerce' );
    1. Which I hope it does in the first place!

  3. Code still works in 2020. Thanks for saving me some developer money.

    1. Great!

  4. excellent

    1. cool

    1. Thanks!

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

    1. Update: WordPress 5.2.2

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

  6. 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!

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

  8. 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 ๐Ÿ™‚

  9. 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? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

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