I have a shop with over 30,000 products per category & I want to limit products show on each category by 1000 only For faster load. The rest of product can only find by search.
How can I do that?
you have to put this code into functions.php file
function product_pagination_by_category() {
if( is_product_category() )
$limit = 10;
return $limit;
}
add_filter( 'loop_shop_per_page', 'product_pagination_by_category');
If you don't want to do custom code then user plugin called Load More Products for WooCommerce.
Load products from next page via AJAX with infinite scrolling or load more products button
FEATURES:
✅ Infinite Scroll for WooCommerce Products
✅ Load More Products Button or AJAX pagination
✅ Custom button text
✅ JavaScript hooks for custom code
check URL : https://wordpress.org/plugins/load-more-products-for-woocommerce/
If you want to go for code then you can check following link. This is already answered:
You can use post_limits
hook to limit total displayed products on product category archive pages:
add_filter( 'post_limits', 'product_category_archives_limit', 10, 2 );
function product_category_archives_limit( $limit, $query ) {
if ( is_product_category() ) {
$limit = 'LIMIT 1000';
}
return $limit;
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
Related: Limit posts on a WP_Query and in WooCommerce product query
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.