Advertisement
bedas

Pagination Fucntion

Sep 1st, 2015
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.26 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Custom template tags for this theme.
  4.  *
  5.  * Eventually, some of the functionality here could be replaced by core features.
  6.  *
  7.  * @package minimax
  8.  */
  9.  
  10. if ( ! function_exists( 'minimax_posts_navigation' ) ) :
  11. /**
  12.  * Display navigation to next/previous set of posts when applicable.
  13.  *
  14.  * @todo Remove this function when WordPress 4.3 is released.
  15.  */
  16. function minimax_posts_navigation() {
  17.     // Don't print empty markup if there's only one page.
  18.     if ( $GLOBALS['wp_query']->max_num_pages < 2 ) {
  19.         return;
  20.     }
  21.     ?>
  22. <nav class="navigation paging-navigation" role="navigation">
  23.     <h1 class="sr-only"><?php _e( 'Posts navigation', 'bootstrapwp' ); ?></h1>
  24.     <ul class="pager">
  25.  
  26.         <?php if ( get_next_posts_link() ) : ?>
  27.         <li class="previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'bootstrapwp' ) ); ?></li>
  28.         <?php endif; ?>
  29.  
  30.         <?php if ( get_previous_posts_link() ) : ?>
  31.         <li class="next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'bootstrapwp' ) ); ?></li>
  32.         <?php endif; ?>
  33.  
  34.     </ul><!-- .nav-links -->
  35. </nav><!-- .navigation -->
  36.     <?php
  37. }
  38. endif;
  39.  
  40. if ( ! function_exists( 'minimax_post_navigation' ) ) :
  41. /**
  42.  * Display navigation to next/previous post when applicable.
  43.  *
  44.  * @todo Remove this function when WordPress 4.3 is released.
  45.  */
  46. function minimax_post_navigation() {
  47.     // Don't print empty markup if there's nowhere to navigate.
  48.     $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
  49.     $next     = get_adjacent_post( false, '', false );
  50.  
  51.     if ( ! $next && ! $previous ) {
  52.         return;
  53.     }
  54.     ?>
  55. <nav class="navigation post-navigation" role="navigation">
  56.     <h1 class="sr-only"><?php _e( 'Post navigation', 'bootstrapwp' ); ?></h1>
  57.     <ul class="pager">
  58.         <?php
  59.     previous_post_link( '<li class="previous">%link</li>', _x( '<span class="meta-nav">&larr;</span>&nbsp;%title', 'Previous post link', 'bootstrapwp' ) );
  60.     next_post_link(     '<li class="next">%link</li>',     _x( '%title&nbsp;<span class="meta-nav">&rarr;</span>', 'Next post link',     'bootstrapwp' ) );
  61.         ?>
  62.     </ul><!-- .nav-links -->
  63. </nav><!-- .navigation -->
  64.     <?php
  65. }
  66. endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement