Advertisement
wekhter

GP Custom next/prev text

Sep 9th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.41 KB | None | 0 0
  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.     ?>
  24.     <nav role="navigation" id="<?php echo esc_attr( $nav_id ); ?>" class="<?php echo $nav_class; ?>">
  25.  
  26.         <?php if ( is_singular( 'post' ) ) : // navigation links for single posts ?>
  27.  
  28.         <?php elseif ( is_singular( 'programpage' ) ) : ?>
  29.  
  30.             <h6 class="screen-reader-text"><?php _e( 'Post navigation', 'generatepress' ); ?></h6>
  31.             <?php if ( get_field( 'lesson_links' ) == 'next_only' ):
  32.                 // null
  33.                 else:
  34.                 previous_post_link( '<div class="nav-previous">%link</div>', '<span class="lesson-nav">Previous</span>' );
  35.                 endif; ?>
  36.             <?php if ( get_field( 'lesson_links' ) == 'previous_only' ):
  37.                 // null
  38.                 else:
  39.                 next_post_link( '<div class="nav-next">%link</div>', '<span class="lesson-nav">Next</span>' );
  40.                 endif; ?>
  41.  
  42.         <?php elseif ( $wp_query->max_num_pages > 1 && ( is_home() || is_archive() || is_search() ) ) : // navigation links for home, archive, and search pages ?>
  43.  
  44.             <?php if ( get_next_posts_link() ) : ?>
  45.             <div class="nav-previous"><span class="prev" title="<?php _e('Previous','generatepress');?>"><?php next_posts_link( __( 'Older posts', 'generatepress' ) ); ?></span></div>
  46.             <?php endif; ?>
  47.  
  48.             <?php if ( get_previous_posts_link() ) : ?>
  49.             <div class="nav-next"><span class="next" title="<?php _e('Next','generatepress');?>"><?php previous_posts_link( __( 'Newer posts', 'generatepress' ) ); ?></span></div>
  50.             <?php endif; ?>
  51.  
  52.             <h6 class="screen-reader-text"><?php _e( 'Post navigation', 'generatepress' ); ?></h6>
  53.             <?php the_posts_navigation(); ?>
  54.             <?php do_action('generate_paging_navigation'); ?>
  55.  
  56.         <?php endif; ?>
  57.  
  58.     </nav><!-- #<?php echo esc_html( $nav_id ); ?> -->
  59.     <?php
  60. }
  61. endif; // generate_content_nav
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement