WooCommerce products per page and List all products

Add below code in function,php to list only particular count product in product list page. Below code will list 12 products per page.

add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 12;' ) );

Use below code to list “All products” in one page.  So, URL should have “URL?showall=1

if( isset( $_GET['showall'] ) ){
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return -1;' ) );
} else {
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 12;' ) );
}

Leave a Reply

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