Guest User

Untitled

a guest
Dec 1st, 2015
158
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if ( ! function_exists( 'generate_content_nav' ) ) :
  2. /**
  3. * Display navigation to next/previous pages when applicable
  4. */
  5. function generate_content_nav( $nav_id ) {
  6.  
  7. global $wp_query, $post;
  8.  
  9. // Don't print empty markup on single pages if there's nowhere to navigate.
  10. if ( is_single() ) {
  11. $previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true );
  12. $next = get_adjacent_post( false, '', false );
  13.  
  14. if ( ! $next && ! $previous )
  15. return;
  16. }
  17.  
  18. // Don't print empty markup in archives if there's only one page.
  19. if ( $wp_query->max_num_pages < 2 && ( is_home() || is_archive() || is_search() ) )
  20. return;
  21.  
  22. $nav_class = ( is_single() ) ? 'post-navigation' : 'paging-navigation';
  23. $category_specific = apply_filters( 'generate_category_post_navigation', false );
  24.  
  25. ?>
  26. <nav id="<?php echo esc_attr( $nav_id ); ?>" class="<?php echo $nav_class; ?>">
  27. <h6 class="screen-reader-text"><?php _e( 'Post navigation', 'generate' ); ?></h6>
  28.  
  29. <?php if ( is_single() ) : // navigation links for single posts ?>
  30.  
  31. <?php previous_post_link( '<div class="nav-previous"><span class="prev" title="' . __('Previous','generate') . '">%link</span></div>', '%title', $category_specific ); ?>
  32. <?php next_post_link( '<div class="nav-next"><span class="next" title="' . __('Next','generate') . '">%link</span></div>', '%title', $category_specific ); ?>
  33.  
  34. <?php elseif ( $wp_query->max_num_pages > 1 && ( is_home() || is_archive() || is_search() ) ) : // navigation links for home, archive, and search pages ?>
  35.  
  36. <?php if ( get_next_posts_link() ) : ?>
  37. <div class="nav-previous"><span class="prev" title="<?php _e('Previous','generate');?>"><?php next_posts_link( __( 'Older posts', 'generate' ) ); ?></span></div>
  38. <?php endif; ?>
  39.  
  40. <?php if ( get_previous_posts_link() ) : ?>
  41. <div class="nav-next"><span class="next" title="<?php _e('Next','generate');?>"><?php previous_posts_link( __( 'Newer posts', 'generate' ) ); ?></span></div>
  42. <?php endif; ?>
  43.  
  44. <?php generate_paging_nav(); ?>
  45. <?php do_action('generate_paging_navigation'); ?>
  46.  
  47. <?php endif; ?>
  48.  
  49. </nav><!-- #<?php echo esc_html( $nav_id ); ?> -->
  50. <?php
  51. }
  52. endif; // generate_content_nav
RAW Paste Data