Permalink
Browse files

Updated pagination.

  • Loading branch information...
awmartin committed Apr 2, 2017
1 parent e86d6de commit 3824de16eee4b7abdd2ba1bad9fae2ba8b194440
Showing with 11 additions and 50 deletions.
  1. +11 −50 null.loop.php
View
@@ -180,6 +180,7 @@ function NullLoop($options=array()) {
$numColumns = $options['num_columns'];
endif;
$closed = false;
while (have_posts()):
the_post();
@@ -202,18 +203,24 @@ function NullLoop($options=array()) {
}
if ($currentPost % $numColumns == 0) {
$closed = false;
echo StartRow();
}
echo EntryLayout($options);
if (($currentPost + 1) % $numColumns == 0) {
$closed = true;
echo EndRow();
}
$currentPost++;
endwhile; // end of the loop.
if (!$closed):
echo EndRow();
endif;
else:
echo '';
// get_template_part( 'no-results', $noResultsTemplate );
@@ -225,57 +232,11 @@ function NullLoop($options=array()) {
return $loopContent;
}
function NullPagination() {
ob_start();
null_content_nav( 'nav-below' );
$pagination = ob_get_contents();
ob_end_clean();
return $pagination;
return NullTag('nav',
NullTag('div', get_next_posts_link( 'Older posts' ), array('class' => 'next older'))
. NullTag('div', get_previous_posts_link( 'Newer posts' ), array('class' => 'previous newer'))
, array('class' => 'pagination'));
}
function null_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() ) ? 'navigation-post' : 'navigation-paging';
?>
<nav role="navigation" id="<?php echo esc_attr( $nav_id ); ?>" class="<?php echo $nav_class; ?>">
<h1 class="screen-reader-text"><?php _e( '', 'null' ); ?></h1>
<?php if ( is_single() ) : // navigation links for single posts ?>
<?php previous_post_link( '<div class="nav-previous">%link</div>', '<span class="meta-nav">' . _x( '&larr;', 'Previous post link', 'null' ) . '</span> %title' ); ?>
<?php next_post_link( '<div class="nav-next">%link</div>', '%title <span class="meta-nav">' . _x( '&rarr;', 'Next post link', 'null' ) . '</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">&larr;</span> Older posts', 'null' ) ); ?></div>
<?php endif; ?>
<?php if ( get_previous_posts_link() ) : ?>
<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'null' ) ); ?></div>
<?php endif; ?>
<?php endif; ?>
</nav><!-- #<?php echo esc_html( $nav_id ); ?> -->
<?php
}
?>

0 comments on commit 3824de1

Please sign in to comment.