Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ( ! function_exists( 'vantage_content_nav' ) ) :
- /**
- * Display navigation to next/previous pages when applicable
- *
- * @since vantage 1.0
- */
- function vantage_content_nav( $nav_id ) {
- $jetpack_infinite_scroll_active = class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'infinite-scroll' );
- //Check if we're in the Page Builder Post Loop widget.
- $is_page_builder_post_loop_widget = class_exists( 'SiteOrigin_Panels_Widgets_PostLoop' ) &&
- method_exists( 'SiteOrigin_Panels_Widgets_PostLoop', 'is_rendering_loop' ) &&
- SiteOrigin_Panels_Widgets_PostLoop::is_rendering_loop();
- if( $jetpack_infinite_scroll_active && ! $is_page_builder_post_loop_widget ) {
- return;
- }
- 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;
- // Add the shorten title filter
- add_filter('the_title', 'vantage_content_nav_shorten_title');
- $nav_class = 'site-navigation paging-navigation';
- if ( is_single() )
- $nav_class = 'site-navigation post-navigation';
- ?>
- <nav role="navigation" id="<?php echo esc_attr( $nav_id ); ?>" class="<?php echo $nav_class; ?>">
- <h1 class="assistive-text"><?php _e( 'Post navigation', 'vantage' ); ?></h1>
- <?php if ( is_single() ) : // navigation links for single posts ?>
- <div class="single-nav-wrapper">
- <?php previous_post_link( '<div class="nav-previous">%link</div>', '<span class="meta-nav">' . _x( '←', 'Previous post link', 'vantage' ) . '</span> %title' ); ?>
- <?php next_post_link( '<div class="nav-next">%link</div>', '%title <span class="meta-nav">' . _x( '→', 'Next post link', 'vantage' ) . '</span>' ); ?>
- </div>
- <?php elseif ( $wp_query->max_num_pages > 1 && ( is_home() || is_archive() || is_search() ) ) : // navigation links for home, archive, and search pages ?>
- <?php vantage_pagination() ?>
- <?php endif; ?>
- </nav><!-- #<?php echo esc_html( $nav_id ); ?> -->
- <?php
- // Remove the shorten title filter
- remove_filter('the_title', 'vantage_content_nav_shorten_title');
- }
- endif; // vantage_content_nav
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement