WooCommerce, Wordpress

How to change number of products displayed per page

28 February 2019

Here, I want to show you how to change number of products displayed per page in woocommerce?

Use the following code to change the number of products show in shop page.

It is required you to have checked in shop page of woocommerce. You have to write this code in “functions.php”

 * Change number of products that are displayed per page (shop 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;

After, adding this code you can also set the return number dynamically via changing the reading options from the backend. You can simply write the “get_option(‘posts_per_page’)” instead of static value 9.

Leave a Comments