Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
WooCommerce - change number of products displayed per page
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;
Copy link

KristinUbute commented Mar 3, 2018

HI, I'm having similar issue cannot get more than 5 products to be viewed for Categories but ONLY on mobile device. Works perfectly viewing 16 products per page on PC/Laptop and ipad.

Using Woocommerce, Storefront theme, Woocommerce products per page and other plugins.

Have also installed WOocommerce Products per page and works on PC/Laptop and Ipad.

But no matter what only 5 products MAX showing on each category for MOBILE ONLY.

Have been googling for days to resolve this issue, no-one seems to know or I haven't found the right support yet !
I see the functions.php snippet everywhere but that doesn't help for the mobile view.

Using WP Touch and just want to ADD in snippet of code to CHANGE the number of products viewed on mobile to 20 per page.
It's across all pages in WOocommerce for mobile.

I tried to find the settings in Theme Storefront and have submitted a ticket but no response to them.
Have submitted a ticket to WP Touch also still waiting.
And submitted on support forum also.

If it displays 2 columns on mobile could this be causing an issue ?
I prefer having 2 columns of products on the mobile ..
as I have the home page which displays 1 product per line and shows more than 5 .. this is the ONLy page that is normal more than 5.
So maybe a line of CSS code to allow it to KNOW more products to be shown more than 5 somehow.

Any help great appreciated.



Copy link

iiiGerardoiii commented Aug 20, 2018

Go to yourdomainname/wp-admin/options-reading.php

@chameleonwebservices that's exactly what I was looking for, I knew it had to be somewhere in the Wordpress settings.

Thanks a lot buddy.

Copy link

Krunal2070 commented Sep 10, 2018

Thanks Work for me.

Copy link

pablo-sg-pacheco commented Dec 7, 2018

If you want to make it work on DIVI theme you can try this approach.
It will override the DIVI settings.

add_filter( 'option_et_divi', function( $option ){
	$option['divi_woocommerce_archive_num_posts'] = 6;
	return $option;
} );

Copy link

gabriel-munteanu commented Feb 7, 2019

If you want to make it work on DIVI theme you can try this approach.
It will override the DIVI settings.

add_filter( 'option_et_divi', function( $option ){
	$option['divi_woocommerce_archive_num_posts'] = 6;
	return $option;
} );

Thanks a lot!

Copy link

peterg23 commented Apr 9, 2019

@pablo-sg-pacheco thank you!

Copy link

PaolaGress commented Mar 11, 2020

@gabriel-munteanu HI there! I´m new in GITHUB. I will appreciate your help with the same issue of Products Per Page in Enfold Theme, for Woocommerce, I´ve tried the code above, I've tried Code Snippets, I've tried similar codes but nothing works for me. It only Return 12 products per Page as default. Thanks in advance.

Copy link

gabriel-munteanu commented Mar 20, 2020

@PaolaGress Maybe you should look in the source code of your theme to check if there is a hard-coded value.
As far as I remember, the code snippet form above was meant to be put inside functions.php in a child theme of your main theme.
Hope this helps!

Copy link

amirshnll commented Jun 4, 2021

add_action( 'woocommerce_product_query', 'woocommerce_product_query' );
function woocommerce_product_query( $q ) {
    if ( $q->is_main_query() && ( $q->get( 'wc_query' ) === 'product_query' ) ) {
        $q->set( 'posts_per_page', '5' );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment