daily pastebin goal
92%
SHARE
TWEET

Untitled

a guest Jul 16th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Num Pagination WP&Bootstrap
  3.  */
  4. if ( ! function_exists ( 'bswp_pagination' ) ) :
  5.     function bswp_pagination($args = [], $class = 'pagination') {
  6.  
  7.         if ( $GLOBALS['wp_query']->max_num_pages <= 1 ) return;
  8.  
  9.         $args = wp_parse_args( $args, [
  10.             'mid_size'           => 2,
  11.             'prev_next'          => false,
  12.             'screen_reader_text' => __('Posts navigation', 'bswp'),
  13.             'type'               => 'array',
  14.             'current'            => max( 1, get_query_var('paged') ),
  15.         ]);
  16.  
  17.         $links     = paginate_links( $args );
  18.  
  19.         ?>
  20.  
  21.         <nav aria-label="<?php echo $args['screen_reader_text']; ?>">
  22.             <ul class="pagination justify-content-center mb-4">
  23.                 <?php
  24.                 $i = 1;
  25.                     foreach ( $links as $link ) { ?>
  26.                         <li class="page-item <?php if ($i == $args['current']) { echo 'active'; }; ?>">
  27.                 <?php echo str_replace( 'page-numbers', 'page-link', $link ); ?>
  28.                         </li>
  29.  
  30.                 <?php $i++;} ?>
  31.             </ul>
  32.         </nav>
  33.         <?php
  34.     }
  35. endif;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top