Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function athemes_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; ?>">
- <h3 class="screen-reader-text"><?php _e( 'Post navigation', 'athemes' ); ?></h3>
- <?php if ( is_single() ) : // navigation links for single posts ?>
- <?php previous_post_link( '<div class="nav-previous"><span>Previous Article</span>%link</div>', '<span class="meta-nav">' . _x( '←', 'Previous post link', 'athemes' ) . '</span> %title' ); ?>
- <?php next_post_link( '<div class="nav-next"><span>Next Article</span>%link</div>', '%title <span class="meta-nav">' . _x( '→', 'Next post link', 'athemes' ) . '</span>' ); ?>
- <?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"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older Articles', 'athemes' ) ); ?></div>
- <?php endif; ?>
- <?php if ( get_previous_posts_link() ) : ?>
- <div class="nav-next"><?php previous_posts_link( __( 'Newer Articles <span class="meta-nav">→</span>', 'athemes' ) ); ?></div>
- <?php endif; ?>
- <?php endif; ?>
- </nav><!-- #<?php echo esc_html( $nav_id ); ?> -->
- <?php
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement