Reply 323997 to: Make pagination show -in between-numbers

Avatar: Olga Barlow
Olga Barlow
Support staff
May 16, 2022 at 12:39

Hello,

Add the below function to your child theme functions.php

function et_woocommerce_pagination() {
		
	$args = array(
		'total'   => wc_get_loop_prop( 'total_pages' ),
		'current' => wc_get_loop_prop( 'current_page' ),
		'base'    => esc_url_raw( add_query_arg( 'product-page', '%#%', false ) ),
		'format'  => '?product-page=%#%',
	);
	
	// @todo make push ajax loaded styles/scripts in footer and prevent load next times
	etheme_enqueue_style( 'pagination', isset($_GET['et_ajax']));
	
	$format = isset( $format ) ? $format : '';
	$base   = esc_url_raw( add_query_arg( 'product-page', '%#%', false ) );
	
	if ( ! wc_get_loop_prop( 'is_shortcode' ) ) {
		$format = '';
		$base   = esc_url_raw( str_replace( 999999999, '%#%', remove_query_arg( 'add-to-cart', wp_specialchars_decode( get_pagenum_link( 999999999 ) ) ) ) );
	}
	
	$total   = isset( $total ) ? $total : wc_get_loop_prop( 'total_pages' );
	$current = isset( $current ) ? $current : wc_get_loop_prop( 'current_page' );

//		$et_per_page  = ( isset( $_REQUEST['et_per_page'] ) ) ? $_REQUEST['et_per_page'] : etheme_get_option( 'products_per_page', 12 );
	$selected_val = ( isset( $_GET['et_per_page'] ) ) ? $_GET['et_per_page'] : false;
	
	return array(
		'base'      => $base,
		'format'    => $format,
		'add_args'  => ( ( ! wc_get_loop_prop( 'is_shortcode' ) && $selected_val ) ? array( 'et_per_page' => $selected_val ) : false ),
		'current'   => max( 1, $current ),
		'total'     => $total,
		'prev_text' => '<i class="et-icon et-'.(is_rtl() ? 'right' : 'left').'-arrow"><span class="screen-reader-text hidden">'.esc_html__('prev', 'xstore').'</span></i>',
		'next_text' => '<i class="et-icon et-'.(is_rtl() ? 'left' : 'right').'-arrow"><span class="screen-reader-text hidden">'.esc_html__('next', 'xstore').'</span></i>',
		'type'      => 'list',
		'end_size'  => 1,
		'mid_size'  => 1,
	);
}

and change the

'end_size'  => 1,
'mid_size'  => 1,

according to your needs.

Regards

Go To The Whole Conversation In Topic
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.