Pawan Kumawat

How To Change The Number Of Products On Shop Page In WooCommerce

In WooCommerce, the number of products displayed on the shop page is controlled by settings in your WordPress dashboard.
There are some common methods to change the number of products on the shop page:

 

**Method 1: Using WooCommerce Settings**
1. Log in to your WordPress admin dashboard.
2. Navigate to “WooCommerce” > “Settings.”
3. Click on the “Products” tab at the top.
4. Under the “Display” section, find the option labeled “Shop Page Display.”
5. Here, you can adjust the “Shop page” value to set the number of products displayed per page. You can choose from options like 12, 24, 36, or a custom number.

Remember to save your changes by clicking the “Save changes” button at the bottom of the page.

 

**Method 2: Using Functions.php (for Customization)**
If you want more control and wish to customize the number of products displayed beyond the options provided in the settings, you can use the `pre_get_posts` action hook in your theme’s `functions.php` file.

1. Log in to your WordPress admin dashboard.
2. Go to “Appearance” > “Theme Editor.”
3. Look for the “functions.php” file in the right-hand side list of theme files.
4. Add the following code at the end of the `functions.php` file:

function custom_woocommerce_products_per_page($query) {
    if (is_shop()) {
        $query->set('posts_per_page', 20); // Change 20 to your desired number of products per page
    }
}
add_action('pre_get_posts', 'custom_woocommerce_products_per_page');

Replace `20` with the desired number of products you want to display per page.

 

**Method 3: Using a Shortcode**
You can override the default shop page settings using a shortcode. For instance, if you want to display 8 products per page, you can add the following shortcode to the shop page content or any page where you want to display the products:

[products per_page="8"]

Change the value to your desired number of products per page.

 

**Method 4: Using a Custom Plugin**
You can achieve this by using a custom plugin that allows you to control various WooCommerce settings. One such plugin is “WooCommerce Customizer,” which enables you to customize different aspects of your WooCommerce store, including the number of products displayed per page.

Here’s how to use the “WooCommerce Customizer” plugin:
1. Install and activate the “WooCommerce Customizer” plugin through the WordPress admin dashboard.
2. Go to “WooCommerce” > “Customizer.”
3. Click on the “Products” tab.
4. Adjust the “Products per page” setting to your desired number.
5. Save the changes.

 

**Method 5: Using Custom Functions.php (with `loop_shop_per_page`)**
You can use the `loop_shop_per_page` filter in your theme’s `functions.php` file to modify the number of products displayed per page. Here’s how:

function custom_woocommerce_products_per_page($cols) {
    return 12; // Change 12 to your desired number of products per page
}
add_filter('loop_shop_per_page', 'custom_woocommerce_products_per_page');

Change `12` to your desired number of products you want to display per page.

 

Categories

Related Blogs

How To Create A Custom Product Tab On Product Page WooCommerce

To create a custom product tab on a WooCommerce product page, you’ll need to use some custom code. WooCommerce provides hooks and filters that allow you to extend and modify its functionality. Below are the steps to create a custom product tab in WooCommerce:

Disable Repeat Purchase Of Product

To disable repeat purchase of products in WooCommerce, you can implement a custom solution using a combination of code snippets and WooCommerce hooks. The idea is to prevent customers from adding the same product to the cart if it already exists in the cart. Below are the steps to achieve this: