Archived topic
Reduce pagination pages/buttons
5 replies · Started by igor96 on July 31, 2020
Hi guys! :)
My pagination bar is overflowing on mobile.
Are there any easy ways to reduce the number of pages in it with GP?
Ciao from Italy ;)
Hi there,
Are you referring to the WooCommerce pagination?
If so that's handled by WooCommerce and I believe this filter would be what you need:
http://hookr.io/filters/woocommerce_pagination_args/
Are you referring to the WooCommerce pagination?
If so that’s handled by WooCommerce and I believe this filter would be what you need:
http://hookr.io/filters/woocommerce_pagination_args/
`
How to use it?
I added both codes, but nothing happened...
my functions.php
https://prnt.sc/1qiu6mw
results:
https://prnt.sc/1qiu79i
Hi there,
You need to add the things you need to change.
You may want to adjust mid size and end size value. That's the number of page links that displays.
By default, it's 3. Change it to your preference.
Example:
// define the woocommerce_pagination_args callback
function filter_woocommerce_pagination_args( $array ) {
$array = array(
'base' => esc_url_raw(str_replace(999999999, '%#%', remove_query_arg('add-to-cart', get_pagenum_link(999999999, false)))),
'format' => '',
'current' => max(1, get_query_var('paged')),
'total' => $wp_query->max_num_pages,
'prev_text' => '←',
'next_text' => '→',
'type' => 'list',
'end_size' => 1,
'mid_size' => 1
);
return $array;
};
// add the filter
add_filter( 'woocommerce_pagination_args', 'filter_woocommerce_pagination_args', 10, 1 );
I added your code to functions.php and now the buttons are gone.
https://prnt.sc/1r7zcpr
https://prnt.sc/1r7zfgs
test site:
https://spojler.ru/shop/
That's a WooCommerce filter so please check with their support team.
You can also Google woocommerce_pagination_args to see some examples.
Thanks.