Site logo

Archived topic

Reduce pagination pages/buttons

5 replies · Started by igor96 on July 31, 2020

Viewing posts 1–6 of 6

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,

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 );

That's a WooCommerce filter so please check with their support team.

You can also Google woocommerce_pagination_args to see some examples.

Thanks.

This archived topic is closed to new replies.