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