Reputation: 2179
I have an online shop which display all products in the shop page.
I use the following code in functions.php:
//EDIT POSTS PER PAGE IN SHOP
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return -1;' ));
When I'm in the main shop page this works without a problem.
But when I'm in a category page, the limit seems to set at 100 and it shows pagination. I don't know where it comes from (in Settings/Reading it's set at 200), or how to change it.
Weirdly enough, if I use the AJAX filters in the category page, when I go back to displaying all, it will show all products without pagination, but on page reload it will show the pagination.
Any tips on how to display all products and get rid of the pagination directly on page load?
Upvotes: 1
Views: 439
Reputation: 3624
Try below code, it is removing pagination and you can apply further condition inside function too.
function no_nopaging($query) {
if ($query->is_archive()) {
$query->set('nopaging', 1);
}
}
add_action('parse_query', 'no_nopaging');
Upvotes: 2