Permalink
Browse files

Merge pull request #38 from kovshenin/patch-6

Don't print markup in _s_content_nav() when it is not needed. Fixes #28. props @kovshenin
  • Loading branch information...
2 parents 5746881 + 6465b5a commit 46f6a664a92c3641dc901cea34ae387e0c7aaaf3 @ianstewart ianstewart committed Sep 14, 2012
Showing with 14 additions and 1 deletion.
  1. +14 −1 inc/template-tags.php
View
@@ -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() )

0 comments on commit 46f6a66

Please sign in to comment.