twentyfourteen_paging_nav

Display navigation to next/previous set of posts when applicable.

Description

twentyfourteen_paging_nav(); 

Usage

  1. if ( !function_exists( 'twentyfourteen_paging_nav' ) ) { 
  2. require_once '/inc/template-tags.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = twentyfourteen_paging_nav(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/inc/template-tags.php  
  1. function twentyfourteen_paging_nav() { 
  2. global $wp_query, $wp_rewrite; 
  3.  
  4. // Don't print empty markup if there's only one page. 
  5. if ( $wp_query->max_num_pages < 2 ) { 
  6. return; 
  7.  
  8. $paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1; 
  9. $pagenum_link = html_entity_decode( get_pagenum_link() ); 
  10. $query_args = array(); 
  11. $url_parts = explode( '?', $pagenum_link ); 
  12.  
  13. if ( isset( $url_parts[1] ) ) { 
  14. wp_parse_str( $url_parts[1], $query_args ); 
  15.  
  16. $pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link ); 
  17. $pagenum_link = trailingslashit( $pagenum_link ) . '%_%'; 
  18.  
  19. $format = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : ''; 
  20. $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%'; 
  21.  
  22. // Set up paginated links. 
  23. $links = paginate_links( array( 
  24. 'base' => $pagenum_link,  
  25. 'format' => $format,  
  26. 'total' => $wp_query->max_num_pages,  
  27. 'current' => $paged,  
  28. 'mid_size' => 1,  
  29. 'add_args' => array_map( 'urlencode', $query_args ),  
  30. 'prev_text' => __( '← Previous', 'twentyfourteen' ),  
  31. 'next_text' => __( 'Next →', 'twentyfourteen' ),  
  32. ) ); 
  33.  
  34. if ( $links ) : 
  35.  
  36. ?> 
  37. <nav class="navigation paging-navigation" role="navigation"> 
  38. <h1 class="screen-reader-text"><?php _e( 'Posts navigation', 'twentyfourteen' ); ?></h1> 
  39. <div class="pagination loop-pagination"> 
  40. <?php echo $links; ?> 
  41. </div><!-- .pagination --> 
  42. </nav><!-- .navigation --> 
  43. <?php 
  44. endif;