skt_pathway_content_nav

Display navigation to next/previous pages when applicable.

Description

skt_pathway_content_nav( $nav_id ); 

Parameters (1)

0. $nav_id
The nav id.

Usage

  1. if ( !function_exists( 'skt_pathway_content_nav' ) ) { 
  2. require_once '/inc/template-tags.php'; 
  3.  
  4. // The nav id. 
  5. $nav_id = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = skt_pathway_content_nav($nav_id); 
  9.  

Defined (1)

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

/inc/template-tags.php  
  1. function skt_pathway_content_nav( $nav_id ) { 
  2. global $wp_query, $post; 
  3.  
  4. // Don't print empty markup on single pages if there's nowhere to navigate. 
  5. if ( is_single() ) { 
  6. $previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true ); 
  7. $next = get_adjacent_post( false, '', false ); 
  8.  
  9. if ( ! $next && ! $previous ) 
  10. return; 
  11.  
  12. // Don't print empty markup in archives if there's only one page. 
  13. if ( $wp_query->max_num_pages < 2 && ( is_home() || is_archive() || is_search() ) ) 
  14. return; 
  15.  
  16. $nav_class = ( is_single() ) ? 'post-navigation' : 'paging-navigation'; 
  17. ?> 
  18. <nav role="navigation" id="<?php echo esc_attr( $nav_id ); ?>" class="<?php echo $nav_class; ?>"> 
  19. <h1 class="screen-reader-text"><?php _e( 'Post navigation', 'skt-pathway' ); ?></h1> 
  20.  
  21. <?php if ( is_single() ) : // navigation links for single posts ?> 
  22.  
  23. <?php previous_post_link( '<div class="nav-previous">%link</div>', '<span class="meta-nav">' . _x( '←', 'Previous post link', 'skt-pathway' ) . '</span> %title' ); ?> 
  24. <?php next_post_link( '<div class="nav-next">%link</div>', '%title <span class="meta-nav">' . _x( '→', 'Next post link', 'skt-pathway' ) . '</span>' ); ?> 
  25.  
  26. <?php elseif ( $wp_query->max_num_pages > 1 && ( is_home() || is_archive() || is_search() ) ) : // navigation links for home, archive, and search pages ?> 
  27.  
  28. <?php if ( get_next_posts_link() ) : ?> 
  29. <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'skt-pathway' ) ); ?></div> 
  30. <?php endif; ?> 
  31.  
  32. <?php if ( get_previous_posts_link() ) : ?> 
  33. <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'skt-pathway' ) ); ?></div> 
  34. <?php endif; ?> 
  35.  
  36. <?php endif; ?> 
  37. <div class="clear"></div> 
  38. </nav><!-- #<?php echo esc_html( $nav_id ); ?> --> 
  39. <?php