2016-11-23 09:42:53 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Pagination layout.
|
|
|
|
*
|
|
|
|
* @package understrap
|
|
|
|
*/
|
|
|
|
|
2018-09-10 21:59:04 +00:00
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
|
|
exit; // Exit if accessed directly.
|
|
|
|
}
|
|
|
|
|
2018-11-18 23:37:12 +00:00
|
|
|
if ( ! function_exists( 'understrap_pagination' ) ) {
|
2018-05-11 19:28:07 +00:00
|
|
|
|
2018-07-12 19:07:38 +00:00
|
|
|
function understrap_pagination( $args = array(), $class = 'pagination' ) {
|
2018-05-11 19:28:07 +00:00
|
|
|
|
2018-11-18 23:37:12 +00:00
|
|
|
if ( $GLOBALS['wp_query']->max_num_pages <= 1 ) {
|
|
|
|
return;
|
|
|
|
}
|
2018-05-11 19:28:07 +00:00
|
|
|
|
2018-11-18 23:37:12 +00:00
|
|
|
$args = wp_parse_args(
|
|
|
|
$args,
|
|
|
|
array(
|
|
|
|
'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' ) ),
|
|
|
|
)
|
|
|
|
);
|
2018-05-11 19:28:07 +00:00
|
|
|
|
2018-11-18 23:37:12 +00:00
|
|
|
$links = paginate_links( $args );
|
2018-05-11 19:28:07 +00:00
|
|
|
|
2018-11-18 23:37:12 +00:00
|
|
|
?>
|
2018-05-11 19:28:07 +00:00
|
|
|
|
2018-11-18 23:37:12 +00:00
|
|
|
<nav aria-label="<?php echo $args['screen_reader_text']; ?>">
|
2018-05-11 19:28:07 +00:00
|
|
|
|
2018-11-18 23:37:12 +00:00
|
|
|
<ul class="pagination">
|
2018-05-11 19:28:07 +00:00
|
|
|
|
2018-11-18 23:37:12 +00:00
|
|
|
<?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
|
|
|
|
}
|
|
|
|
?>
|
2018-05-11 19:28:07 +00:00
|
|
|
|
2018-11-18 23:37:12 +00:00
|
|
|
</ul>
|
2018-05-11 19:28:07 +00:00
|
|
|
|
2018-11-18 23:37:12 +00:00
|
|
|
</nav>
|
2018-05-11 19:28:07 +00:00
|
|
|
|
2018-11-18 23:37:12 +00:00
|
|
|
<?php
|
|
|
|
}
|
2018-05-05 08:09:27 +00:00
|
|
|
}
|
2018-05-11 19:28:07 +00:00
|
|
|
|
|
|
|
?>
|