Show more products per page on WooCommerce product archive

WordPress code snippet to change the number of products per page on WooCommerce product archive

Changing the number of products per page on WooCommerce can be done in may ways, the easiest is to take advantage of the loop_shop_per_page filter that returns the number of products being displayed. Adding the following code snippet to your themes functions.php file will allow you to set the number of products displayed by changing the $product_per_page variable from 24 to the number of products you want displayed.

/**
 * Update the number of products displayed on WooCommerce Product Archive
 * 
 * @param int $products_per_page 
 * @return int 
 */
function jcwc_set_woocommerce_products_per_age( $products_per_page ) {
  $products_per_page = 24;
  return $products_per_page;
}
add_filter( 'loop_shop_per_page', 'jcwc_set_woocommerce_products_per_age', PHP_INT_MAX );

Leave a Reply

Fields marked with an * are required to post a comment