Created
February 25, 2018 12:59
-
-
Save mlbd/8b455590848feba94371746a95ad9187 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
// WordPress pagination for boostrap 4 | |
if ( !function_exists( 'wpse64458_pagination' ) ) { | |
function wpse64458_pagination(){ | |
global $wp_query; | |
ob_start(); | |
$translated = esc_html__( 'Page', 'wpse64458' ); // Supply translatable string | |
$pagination = paginate_links( array( | |
'base' => str_replace( PHP_INT_MAX, '%#%', esc_url( get_pagenum_link( PHP_INT_MAX ) ) ), | |
'format' => '?paged=%#%', | |
'current' => max( 1, get_query_var('paged') ), | |
'total' => $wp_query->max_num_pages, | |
'type' => 'array', | |
'prev_text' => __('<span></span> Prev', 'wpse64458'), | |
'next_text' => __('Next <span></span>', 'wpse64458'), | |
'before_page_number' => '<span class="screen-reader-text">' . $translated . ' </span>' | |
) ); | |
if ( ! empty( $pagination ) ) : ?> | |
<ul class="pagination pagination-lg wpse64458_pagination"> | |
<?php foreach ( $pagination as $key => $page_link ) : ?> | |
<li class="page-item<?php if ( strpos( $page_link, 'current' ) !== false ) { echo ' active'; } ?>"><?php echo str_replace( 'page-numbers', 'page-link', $page_link ); ?></li> | |
<?php endforeach ?> | |
</ul> | |
<?php endif; | |
echo ob_get_clean(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment