Advertisement
Guest User

nav

a guest
Jul 11th, 2014
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. <?php
  2.  
  3. function athemes_content_nav( $nav_id ) {
  4. global $wp_query, $post;
  5.  
  6. // Don't print empty markup on single pages if there's nowhere to navigate.
  7. if ( is_single() ) {
  8. $previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true );
  9. $next = get_adjacent_post( false, '', false );
  10.  
  11. if ( ! $next && ! $previous )
  12. return;
  13. }
  14.  
  15. // Don't print empty markup in archives if there's only one page.
  16. if ( $wp_query->max_num_pages < 2 && ( is_home() || is_archive() || is_search() ) )
  17. return;
  18.  
  19. $nav_class = ( is_single() ) ? 'post-navigation' : 'paging-navigation';
  20.  
  21. ?>
  22. <nav role="navigation" id="<?php echo esc_attr( $nav_id ); ?>" class="<?php echo $nav_class; ?>">
  23. <h3 class="screen-reader-text"><?php _e( 'Post navigation', 'athemes' ); ?></h3>
  24.  
  25. <?php if ( is_single() ) : // navigation links for single posts ?>
  26.  
  27. <?php previous_post_link( '<div class="nav-previous"><span>Previous Article</span>%link</div>', '<span class="meta-nav">' . _x( '&larr;', 'Previous post link', 'athemes' ) . '</span> %title' ); ?>
  28. <?php next_post_link( '<div class="nav-next"><span>Next Article</span>%link</div>', '%title <span class="meta-nav">' . _x( '&rarr;', 'Next post link', 'athemes' ) . '</span>' ); ?>
  29.  
  30. <?php elseif ( $wp_query->max_num_pages > 1 && ( is_home() || is_archive() || is_search() ) ) : // navigation links for home, archive, and search pages ?>
  31.  
  32. <?php if ( get_next_posts_link() ) : ?>
  33. <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older Articles', 'athemes' ) ); ?></div>
  34. <?php endif; ?>
  35.  
  36. <?php if ( get_previous_posts_link() ) : ?>
  37. <div class="nav-next"><?php previous_posts_link( __( 'Newer Articles <span class="meta-nav">&rarr;</span>', 'athemes' ) ); ?></div>
  38. <?php endif; ?>
  39.  
  40. <?php endif; ?>
  41.  
  42. </nav><!-- #<?php echo esc_html( $nav_id ); ?> -->
  43. <?php
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement