Control Number of Products Per Page in WooCommerce

Posted on by Dan Pock | Updated:
Reading Time: 2 minutes

A common question that comes up after someone gets their WooCommerce store setup is about customization. Setting up your store and getting the products loaded in is just part of running any web store. One of the biggest benefits to WooCommerce is the opportunity for customization.

In the coming posts on WooCommerce we'll explore some basic customization tasks that come up. Starting with a simple one, say you wanted to adjust the number of products that are shown per page in your shop.

How Can I Change the Number of Products Per Page?

There are several options available to change the number of products per page. You may only be able to use a few of the methods we'll provide. Since some of the methods are only supported based on your site's theme we'll include a few methods.

Method 1: Using the Theme Customizer

Without a doubt this is the easiest method to do this task with. That said, your mileage may vary – this is a method your theme must support to have available.

  1. From within your WordPress Admin area, find and hover your mouse on the Appearance option.
  2. Inside of the Appearance dropdown click the Customize option. This will open the WordPress theme customizer tool.
  3. Within this tool click the Layout option. If your theme supports it, you will see a Shop Posts per Page where you can control the number of products per page.
    Appearance option

If you do not see this option, like the example, then your theme does not have support for this customization option. Don't worry though, you can still customize this with the other method bellow!

Method 2: Adjust the Setting Using a Filter

If your theme does not have the option, with a little bit of code, you can achieve the same results. So just a little bit a code is needed to do this. Before you go copying and pasting code though you should read our article on managing code snippets. Once you've read that article and brushed up on modifying code in WordPress continue on.

Add the following code to your theme’s `functions.php` file, or you can manage the code using the code snippets plugin.

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

Keep in mind, our example sets the products per page to 9 - in a 3 column page this will be 3 rows. So, when you set this number you should be aware of the number of columns your layout has currently.

Give us a call at 800.580.4985, or open a chat or ticket with us to speak with one of our knowledgeable Solutions Team or an experienced Hosting Advisors today!

Avatar for Dan Pock

About the Author: Dan Pock

Dan Pock does technical support at Liquid Web with a background in System Administration, Public Relations, and Customer Service. His favorite things include his cats, Oscar Boots, and Dash Nougat; experimenting with PHP; and making up recipes (or at least attempting to). You can find his coding hijinks on GitHub, where he shares most of his projects and open source work.

Latest Articles

Blocking IP or whitelisting IP addresses with UFW

Read Article

CentOS Linux 7 end of life migrations

Read Article

Use ChatGPT to diagnose and resolve server issues

Read Article

What is SDDC VMware?

Read Article

Best authentication practices for email senders

Read Article