Advertisement
MrPauloeN

Custom Blog Posts Pagination for Bootstrap Theme

Apr 4th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1.     /*
  2.      * Custom Blog Posts Pagination for Bootstrap Theme
  3.      *
  4.      *  This function is replacement for:
  5.      *  @the_posts_pagination();
  6.      *  and is used on home.php template, line: 55
  7.      *
  8.      *  It shows nice and clear posts pagination tailored to Bootstrap Theme
  9.      *
  10.      * @since The Bootstrap Blog 0.1
  11.      **/
  12.      
  13. function the_bootstrap_blog__the_posts_pagination(){
  14.     global $wp_query;
  15.  
  16. if ( $wp_query->max_num_pages > 1 ) {
  17.  
  18.     $n = "\n";
  19.  
  20.     $next = get_next_posts_link( __( 'Older', 'the-bootstrap-blog' ) );
  21.  
  22.     if ( get_query_var( 'paged' ) == '0' ) {
  23.  
  24.         $prev = '<a class="btn btn-outline-secondary disabled" href="#">' . __( 'Newer', 'the-bootstrap-blog' ) . '</a>';
  25.     } else {
  26.  
  27.         $prev = get_previous_posts_link( __( 'Newer', 'the-bootstrap-blog' ) );
  28.     }
  29.  
  30.     $posts_pagination = '<nav class="blog-pagination">' . $n . $next . $n . $prev . $n . '</nav>';
  31.  
  32.     return $posts_pagination;
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement