summaryrefslogtreecommitdiff
path: root/inc/pagination.php
diff options
context:
space:
mode:
authorMax2018-10-15 23:46:42 +0200
committerMax2018-10-15 23:46:42 +0200
commit00c9709fd9763542e848f6278db8ba26af5c9886 (patch)
tree92cb1c1ee4c467118e1e5a4c7e233d3feac6efa8 /inc/pagination.php
downloadfuselkoenig_de-00c9709fd9763542e848f6278db8ba26af5c9886.tar.gz
Initial commit.
Diffstat (limited to 'inc/pagination.php')
-rw-r--r--inc/pagination.php56
1 files changed, 56 insertions, 0 deletions
diff --git a/inc/pagination.php b/inc/pagination.php
new file mode 100644
index 0000000..9a6ff79
--- /dev/null
+++ b/inc/pagination.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Pagination layout.
+ *
+ * @package understrap
+ */
+
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly.
+}
+
+if ( ! function_exists ( 'understrap_pagination' ) ) {
+
+ function understrap_pagination( $args = array(), $class = 'pagination' ) {
+
+ if ($GLOBALS['wp_query']->max_num_pages <= 1) return;
+
+ $args = wp_parse_args( $args, array(
+ 'mid_size' => 2,
+ 'prev_next' => true,
+ 'prev_text' => __('&laquo;', 'understrap'),
+ 'next_text' => __('&raquo;', '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
+
+ 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
+ }
+}
+
+?>