twentyfourteen_post_nav

Display navigation to next/previous post when applicable.

Description

twentyfourteen_post_nav(); 

Usage

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

Defined (1)

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

/inc/template-tags.php  
  1. function twentyfourteen_post_nav() { 
  2. // Don't print empty markup if there's nowhere to navigate. 
  3. $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true ); 
  4. $next = get_adjacent_post( false, '', false ); 
  5.  
  6. if ( ! $next && ! $previous ) { 
  7. return; 
  8.  
  9. ?> 
  10. <nav class="navigation post-navigation" role="navigation"> 
  11. <h1 class="screen-reader-text"><?php _e( 'Post navigation', 'twentyfourteen' ); ?></h1> 
  12. <div class="nav-links"> 
  13. <?php 
  14. if ( is_attachment() ) : 
  15. previous_post_link( '%link', __( '<span class="meta-nav">Published In</span>%title', 'twentyfourteen' ) ); 
  16. else : 
  17. previous_post_link( '%link', __( '<span class="meta-nav">Previous Post</span>%title', 'twentyfourteen' ) ); 
  18. next_post_link( '%link', __( '<span class="meta-nav">Next Post</span>%title', 'twentyfourteen' ) ); 
  19. endif; 
  20. ?> 
  21. </div><!-- .nav-links --> 
  22. </nav><!-- .navigation --> 
  23. <?php