Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Don't print markup in _s_content_nav() when it is not needed. Fixes #28. #38

Merged
merged 1 commit into from

2 participants

@kovshenin
Owner

Added checks for previous (or parent) and next post in _s_content_nav() before printing any navigation-specific markup. Same approach for when using the function to print pagination links on a posts set for less than two pages.

@kovshenin kovshenin Don't print markup in _s_content_nav() when it is not needed. Fixes #28.
Added checks for previous (or parent) and next post in _s_content_nav() before printing any navigation-specific markup. Same approach for when using the function to print pagination links on a posts set for less than two pages.
6465b5a
@ianstewart ianstewart merged commit 46f6a66 into Automattic:master
@kovshenin
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 15, 2012
  1. @kovshenin

    Don't print markup in _s_content_nav() when it is not needed. Fixes #28.

    kovshenin authored
    Added checks for previous (or parent) and next post in _s_content_nav() before printing any navigation-specific markup. Same approach for when using the function to print pagination links on a posts set for less than two pages.
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 1 deletion.
  1. +14 −1 inc/template-tags.php
View
15 inc/template-tags.php
@@ -15,7 +15,20 @@
* @since _s 1.0
*/
function _s_content_nav( $nav_id ) {
- global $wp_query;
+ 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 = 'site-navigation paging-navigation';
if ( is_single() )
Something went wrong with that request. Please try again.