Skip to content

Instantly share code, notes, and snippets.

@kbcarte
Created April 29, 2023 16:56
Show Gist options
  • Save kbcarte/e9dca58f03746b66cc79e04ac880ace1 to your computer and use it in GitHub Desktop.
Save kbcarte/e9dca58f03746b66cc79e04ac880ace1 to your computer and use it in GitHub Desktop.
<?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