Advertisement
blackimpala

code pagination bootstrap

Feb 24th, 2020
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 KB | None | 0 0
  1.  
  2. /*########################################################################
  3. /////////////////////// Codigo Paginación con Bootstrap \\\\\\\\\\\\\\\\\\
  4. ##########################################################################*/
  5.  
  6. if (! function_exists('gymclub_pagination_crud')) {
  7.     function gymclub_pagination_crud(){
  8.         global $wp_query;
  9.         $pages = paginate_links( [
  10.             'format'     => '?paged=%#%',
  11.             'current'    => max( 1, get_query_var( 'paged' ) ),
  12.             'total'      => $wp_query->max_num_pages,
  13.             'type'       => 'array',
  14.             'show_all'   => false,
  15.             'end_size'   => 3,
  16.             'mid_size'   => 1,
  17.             'prev_next'  => true,
  18.             'prev_text'  => __( '<< Anterior', 'gymclub' ),
  19.             'next_text'  => __( 'Siguiente >>', 'gymclub' ),
  20.             'add_args'   => false
  21.             ]
  22.         );
  23.  
  24.         if ( is_array( $pages )) {
  25.             $pagination = '<div class="clearfix"></div><ul class="pagination">';
  26.             foreach ($pages as $page) {
  27.                 $pagination .= '<li class="page-item ' .(strpos($page, 'current') !== false ? 'active' : ''). '"> ' . str_replace( 'page-numbers','page-link', $page ). '</li>';
  28.             }
  29.             $pagination .= '</ul>';
  30.             return $pagination;
  31.         }
  32.            return null;
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement