1function njengah_pagination() {
2
3 if( is_singular() )
4
5 return;
6
7 global $wp_query;
8
9 $paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
10
11 $max = intval( $wp_query->max_num_pages );
12
13 /** Add current page to the array */
14
15 if ( $paged >= 1 )
16
17 $links[] = $paged;
18
19 /** Add the pages around the current page to the array */
20
21 if ( $paged >= 5 ) {
22
23 $links[] = $paged - 1;
24
25 $links[] = $paged - 2;
26
27 }
28 echo '<div class="navigation"><ul>' . "\n";
29
30 /** Previous Post Link */
31
32 if ( get_previous_posts_link() )
33
34 printf( '<li>%s</li>' . "\n", get_previous_posts_link() );
35
36 /** Link to first page */
37
38 if ( ! in_array( 1, $links ) ) {
39
40 $class = 1 == $paged ? ' class="active"' : '';
41
42
43
44
45 printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
46
47 }
48 /** Link to current page*/
49
50 sort( $links );
51
52 foreach ( (array) $links as $link ) {
53
54 $class = $paged == $link ? ' class="active"' : '';
55
56 }
57
58 /** Link to last page,*/
59
60 if ( ! in_array( $max, $links ) ) {
61
62 if ( ! in_array( $max - 1, $links ) )
63
64 echo '<li>…</li>' . "\n";
65 $class = $paged == $max ? ' class="active"' : '';
66
67 }
68
69 /** Next Post Link */
70
71 if ( get_next_posts_link() )
72
73 printf( '<li>%s</li>' . "\n", get_next_posts_link() );
74 echo '</ul></div>' . "\n";
75
76}
1<?php
2/**
3 * Pagination - Show numbered pagination for catalog pages
4 *
5 * This template can be overridden by copying it to yourtheme/woocommerce/loop/pagination.php.
6 *
7 * HOWEVER, on occasion WooCommerce will need to update template files and you
8 * (the theme developer) will need to copy the new files to your theme to
9 * maintain compatibility. We try to do this as little as possible, but it does
10 * happen. When this occurs the version of the template file will be bumped and
11 * the readme will list any important changes.
12 *
13 * @see https://docs.woocommerce.com/document/template-structure/
14 * @package WooCommerce\Templates
15 * @version 3.3.1
16 */
17
18if ( ! defined( 'ABSPATH' ) ) {
19 exit;
20}
21
22$total = isset( $total ) ? $total : wc_get_loop_prop( 'total_pages' );
23$current = isset( $current ) ? $current : wc_get_loop_prop( 'current_page' );
24$base = isset( $base ) ? $base : esc_url_raw( str_replace( 999999999, '%#%', remove_query_arg( 'add-to-cart', get_pagenum_link( 999999999, false ) ) ) );
25$format = isset( $format ) ? $format : '';
26
27if ( $total <= 1 ) {
28 return;
29}
30?>
31<nav class="woocommerce-pagination">
32 <?php
33 echo paginate_links(
34 apply_filters(
35 'woocommerce_pagination_args',
36 array( // WPCS: XSS ok.
37 'base' => $base,
38 'format' => $format,
39 'add_args' => false,
40 'current' => max( 1, $current ),
41 'total' => $total,
42 'prev_text' => '←',
43 'next_text' => '→',
44 'type' => 'list',
45 'end_size' => 3,
46 'mid_size' => 3,
47 )
48 )
49 );
50 ?>
51</nav>