How to show all product without pagination by woocommerce plugin in wordpress?

Mohammad Shafeeq picture Mohammad Shafeeq · Nov 15, 2016 · Viewed 9.3k times · Source

I need to remove pagination from shop-collection page and want to show all product in one page. How its possible by woocommerce plugin ? I'm using latest wordpress and latest woocommerce plugin

Thanks

Answer

parameciostudio picture parameciostudio · Aug 3, 2017

You can use woocommerce_product_query hook:

add_action( 'woocommerce_product_query', 'all_products_query' );

function all_products_query( $q ){
    $q->set( 'posts_per_page', -1 );
}

This hook adds your code at the bottom of the function product_query.

From the code:

/** * Query the products, applying sorting/ordering etc. This applies to the main wordpress loop. * * @param mixed $q */

public function product_query( $q ) 

Query the products, applying sorting/ordering etc. This applies to the main wordpress loop.