Created
April 29, 2023 16:56
-
-
Save kbcarte/e9dca58f03746b66cc79e04ac880ace1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Yoink https://wordpress.stackexchange.com/a/154364 | |
if ( ! function_exists( 'pagination' ) ) { | |
function pagination( $paged = '', $max_page = '' ) { | |
$big = 999999999; // need an unlikely integer | |
if( ! $paged ) { | |
$paged = get_query_var('paged'); | |
} | |
if( ! $max_page ) { | |
global $wp_query; | |
$max_page = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1; | |
} | |
echo paginate_links( array( | |
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), | |
'format' => '?paged=%#%', | |
'current' => max( 1, $paged ), | |
'total' => $max_page, | |
'mid_size' => 1, | |
'prev_text' => __( '«' ), | |
'next_text' => __( '»' ), | |
'type' => 'list' | |
) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment