Home » WordPress » WooCommerce Change number of products displayed per page

WooCommerce Change number of products displayed per page

By default, WooCommerce shows 16 products in 4 rows and four columns on a shop page,

if you are not happy with that you can use following  code to change the number of WooCommerce products displayed per page.

Open your function.php and add bellow code:


function new_loop_shop_per_page($cols)
{

// $cols contains the current number of products per page based on the value stored on Options –> Reading
$cols = 9;
return $cols;
}
add_filter('loop_shop_per_page', 'new_loop_shop_per_page', 20);

Also if you want to conditionaly change the products per page, you can do something like this bellow. here we show 6 products per page in woocommerce shop page and shows 9 products in category page


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 want to show per page.

if (is_shop()) {
$cols = 6;
} else if (is_product_category()) {
$cols = 9;
}
return $cols;
}
add_filter('loop_shop_per_page', 'new_loop_shop_per_page', 20);

References

Duminda Wijerathna

An all round web designer building websites Over 18 years. Interested in achieving a suitable placement in the field of IT in a growth oriented organization which offers diverse job responsibilities in order to utilize and improve my skills, Knowledge and experience.

Leave a Comment

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