true, 'query' => $GLOBALS['wp_query'], 'show_all' => false, 'prev_next' => true, 'prev_text' => __('Previous Page', 'enollo'), 'next_text' => __('Next Page', 'enollo'), ); $args = wp_parse_args( $args, $defaults ); extract($args, EXTR_SKIP); // Stop execution if there's only 1 page if( $query->max_num_pages <= 1 ) { return; } $pagination = ''; $links = array(); $paged = max( 1, absint( $query->get( 'paged' ) ) ); $max = intval( $query->max_num_pages ); if ( $show_all ) { $links = range(1, $max); } else { // Add the pages before the current page to the array if ( $paged >= 2 + 1 ) { $links[] = $paged - 2; $links[] = $paged - 1; } // Add current page to the array if ( $paged >= 1 ) { $links[] = $paged; } // Add the pages after the current page to the array if ( ( $paged + 2 ) <= $max ) { $links[] = $paged + 1; $links[] = $paged + 2; } } $pagination .= "\n" . '