Update pagination.php
1. Dynamic prev and next 1. Improved active class 1. Improved ellipsis
This commit is contained in:
parent
e59538ad22
commit
f8dd00d1c4
|
@ -6,38 +6,47 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! function_exists ( 'understrap_pagination' ) ) {
|
if ( ! function_exists ( 'understrap_pagination' ) ) {
|
||||||
function understrap_pagination($args = [], $class = 'pagination') {
|
|
||||||
|
|
||||||
if ($GLOBALS['wp_query']->max_num_pages <= 1) return;
|
function understrap_pagination($args = [], $class = 'pagination') {
|
||||||
|
|
||||||
$args = wp_parse_args( $args, [
|
if ($GLOBALS['wp_query']->max_num_pages <= 1) return;
|
||||||
'mid_size' => 2,
|
|
||||||
'prev_next' => true,
|
|
||||||
'prev_text' => __('«', 'understrap'),
|
|
||||||
'next_text' => __('»', 'understrap'),
|
|
||||||
'screen_reader_text' => __('Posts navigation', 'understrap'),
|
|
||||||
'type' => 'array',
|
|
||||||
'current' => max( 1, get_query_var('paged') ),
|
|
||||||
]);
|
|
||||||
|
|
||||||
$links = paginate_links($args);
|
$args = wp_parse_args( $args, [
|
||||||
|
'mid_size' => 2,
|
||||||
|
'prev_next' => true,
|
||||||
|
'prev_text' => __('«', 'understrap'),
|
||||||
|
'next_text' => __('»', 'understrap'),
|
||||||
|
'screen_reader_text' => __('Posts navigation', 'understrap'),
|
||||||
|
'type' => 'array',
|
||||||
|
'current' => max( 1, get_query_var('paged') ),
|
||||||
|
]);
|
||||||
|
|
||||||
?>
|
$links = paginate_links($args);
|
||||||
|
|
||||||
<nav aria-label="<?php echo $args['screen_reader_text']; ?>">
|
?>
|
||||||
<ul class="pagination">
|
|
||||||
|
|
||||||
<?php
|
|
||||||
$i = 1;
|
|
||||||
foreach ( $links as $link ) { ?>
|
|
||||||
<li class="page-item <?php if ($i == $args['current']) { echo 'active'; }; ?>">
|
|
||||||
<?php echo str_replace( 'page-numbers', 'page-link', $link ); ?>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<?php $i++;} ?>
|
<nav aria-label="<?php echo $args['screen_reader_text']; ?>">
|
||||||
|
|
||||||
</ul>
|
<ul class="pagination">
|
||||||
</nav>
|
|
||||||
<?php
|
<?php
|
||||||
}
|
|
||||||
|
foreach ( $links as $key => $link ) { ?>
|
||||||
|
|
||||||
|
<li class="page-item <?php echo strpos( $link, 'current' ) ? 'active' : '' ?>">
|
||||||
|
|
||||||
|
<?php echo str_replace( 'page-numbers', 'page-link', $link ); ?>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
Reference in New Issue