How to change the number of Products being displayed using the Main Query on Archive pages?
In order to change the number of products that are being displayed using the Main Query, we need to use a bit of Custom Code.
“Main Query” uses the default WP_Query so, the number of products to be displayed is controlled by WooCommerce.
WooCommerce by default shows only 16 products via Main Query, so you will need to use a bit of custom code to allow a specific number of products while selecting the source as “Main Query”.
Please add the following code in the theme’s functions.php file:
// Change the Number of WooCommerce Products Displayed Per Page
add_filter( 'loop_shop_per_page', function( $per_page ) {
return 12; // number of products that you want to display per page.
}, 20 );
You can change the number of products to show by changing “12” to the number of products you want to display.