Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ( ! function_exists( 'generate_content_nav' ) ) :
- /**
- * Display navigation to next/previous pages when applicable
- */
- function generate_content_nav( $nav_id ) {
- global $wp_query, $post;
- // Don't print empty markup on single pages if there's nowhere to navigate.
- if ( is_single() ) {
- $previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true );
- $next = get_adjacent_post( false, '', false );
- if ( ! $next && ! $previous )
- return;
- }
- // Don't print empty markup in archives if there's only one page.
- if ( $wp_query->max_num_pages < 2 && ( is_home() || is_archive() || is_search() ) )
- return;
- $nav_class = ( is_single() ) ? 'post-navigation' : 'paging-navigation';
- ?>
- <nav role="navigation" id="<?php echo esc_attr( $nav_id ); ?>" class="<?php echo $nav_class; ?>">
- <?php if ( is_singular( 'post' ) ) : // navigation links for single posts ?>
- <?php elseif ( is_singular( 'programpage' ) ) : ?>
- <h6 class="screen-reader-text"><?php _e( 'Post navigation', 'generatepress' ); ?></h6>
- <?php if ( get_field( 'lesson_links' ) == 'next_only' ):
- // null
- else:
- previous_post_link( '<div class="nav-previous">%link</div>', '<span class="lesson-nav">Previous</span>' );
- endif; ?>
- <?php if ( get_field( 'lesson_links' ) == 'previous_only' ):
- // null
- else:
- next_post_link( '<div class="nav-next">%link</div>', '<span class="lesson-nav">Next</span>' );
- endif; ?>
- <?php elseif ( $wp_query->max_num_pages > 1 && ( is_home() || is_archive() || is_search() ) ) : // navigation links for home, archive, and search pages ?>
- <?php if ( get_next_posts_link() ) : ?>
- <div class="nav-previous"><span class="prev" title="<?php _e('Previous','generatepress');?>"><?php next_posts_link( __( 'Older posts', 'generatepress' ) ); ?></span></div>
- <?php endif; ?>
- <?php if ( get_previous_posts_link() ) : ?>
- <div class="nav-next"><span class="next" title="<?php _e('Next','generatepress');?>"><?php previous_posts_link( __( 'Newer posts', 'generatepress' ) ); ?></span></div>
- <?php endif; ?>
- <h6 class="screen-reader-text"><?php _e( 'Post navigation', 'generatepress' ); ?></h6>
- <?php the_posts_navigation(); ?>
- <?php do_action('generate_paging_navigation'); ?>
- <?php endif; ?>
- </nav><!-- #<?php echo esc_html( $nav_id ); ?> -->
- <?php
- }
- endif; // generate_content_nav
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement