parent
33adc3f6a7
commit
aaf056be3e
|
@ -5024,13 +5024,15 @@ a.skip-link {
|
||||||
margin-right: .425rem;
|
margin-right: .425rem;
|
||||||
margin-left: .425rem; }
|
margin-left: .425rem; }
|
||||||
|
|
||||||
.post-navigation {
|
.post-navigation,
|
||||||
|
.paged-navigation {
|
||||||
padding-top: 1rem;
|
padding-top: 1rem;
|
||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
border-top: 1px solid #373a3c; }
|
border-top: 1px solid #373a3c; }
|
||||||
|
|
||||||
.nav-previous a,
|
.nav-previous a,
|
||||||
.nav-next a {
|
.nav-next a,
|
||||||
|
.paged-navigation a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: #373a3c; }
|
color: #373a3c; }
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -154,3 +154,72 @@ if ( ! function_exists( 'understrap_post_nav' ) ) :
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom Pagination with numbers
|
||||||
|
* Credits to http://www.wpbeginner.com/wp-themes/how-to-add-numeric-pagination-in-your-wordpress-theme/
|
||||||
|
*/
|
||||||
|
if ( ! function_exists( 'understrap_numeric_posts_nav' ) ) :
|
||||||
|
function understrap_numeric_posts_nav() {
|
||||||
|
if( is_singular() )
|
||||||
|
return;
|
||||||
|
global $wp_query;
|
||||||
|
/** Stop execution if there's only 1 page */
|
||||||
|
if( $wp_query->max_num_pages <= 1 )
|
||||||
|
return;
|
||||||
|
$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
|
||||||
|
$max = intval( $wp_query->max_num_pages );
|
||||||
|
/** Add current page to the array */
|
||||||
|
if ( $paged >= 1 )
|
||||||
|
$links[] = $paged;
|
||||||
|
/** Add the pages around the current page to the array */
|
||||||
|
if ( $paged >= 3 ) {
|
||||||
|
$links[] = $paged - 1;
|
||||||
|
$links[] = $paged - 2;
|
||||||
|
}
|
||||||
|
if ( ( $paged + 2 ) <= $max ) {
|
||||||
|
$links[] = $paged + 2;
|
||||||
|
$links[] = $paged + 1;
|
||||||
|
}
|
||||||
|
echo '<div class="nav-links paged-navigation">' . "\n";
|
||||||
|
/** Previous Post Link */
|
||||||
|
if ( get_previous_posts_link() ) {
|
||||||
|
//printf( '<button class="nav-previous btn btn-ghost btn-raised"><span class="fa fa-backward"></span> %s</button>' . "\n", get_previous_posts_link() );
|
||||||
|
?>
|
||||||
|
<span class="nav-previous btn btn-sm btn-secondary">
|
||||||
|
<?php previous_posts_link( '<span class="fa fa-backward"></span> '. __('Newer posts', 'understrap' )); ?>
|
||||||
|
</span>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
/** Link to first page, plus ellipses if necessary */
|
||||||
|
if ( ! in_array( 1, $links ) ) {
|
||||||
|
$class = 1 == $paged ? 'active' : '';
|
||||||
|
printf( '<span class="btn btn-sm btn-secondary pagenumbers %s"><a href="%s">%s</a></span>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
|
||||||
|
if ( ! in_array( 2, $links ) )
|
||||||
|
echo '<span class="btn btn-sm btn-secondary">...</span>';
|
||||||
|
}
|
||||||
|
/** Link to current page, plus 2 pages in either direction if necessary */
|
||||||
|
sort( $links );
|
||||||
|
foreach ( (array) $links as $link ) {
|
||||||
|
$class = $paged == $link ? 'active' : '';
|
||||||
|
printf( '<span class="btn btn-sm btn-secondary pagenumbers %s"><a href="%s">%s</a></span>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
|
||||||
|
}
|
||||||
|
/** Link to last page, plus ellipses if necessary */
|
||||||
|
if ( ! in_array( $max, $links ) ) {
|
||||||
|
if ( ! in_array( $max - 1, $links ) )
|
||||||
|
echo '<span class="btn btn-sm btn-secondary">...</span>' . "\n";
|
||||||
|
$class = $paged == $max ? ' active' : '';
|
||||||
|
printf( '<span class="btn btn-sm btn-secondary pagenumbers %s"><a href="%s">%s</a></span>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
|
||||||
|
}
|
||||||
|
/** Next Post Link */
|
||||||
|
if ( get_next_posts_link() ) {
|
||||||
|
//printf( '<button class="nav-next btn btn-ghost btn-raised pull-right">%s <span class="fa fa-forward"></span></button>' . "\n", get_next_posts_link() );
|
||||||
|
?>
|
||||||
|
<span class="nav-next btn btn-sm btn-secondary float-xs-right">
|
||||||
|
<?php next_posts_link( __('Older posts', 'understrap' ) . ' <span class="fa fa-forward"></span>'); ?>
|
||||||
|
</span>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
echo '</div>' . "\n";
|
||||||
|
}
|
||||||
|
endif;
|
|
@ -130,14 +130,16 @@ a.skip-link {
|
||||||
margin-left: .425rem;
|
margin-left: .425rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-navigation {
|
.post-navigation,
|
||||||
|
.paged-navigation {
|
||||||
padding-top: 1rem;
|
padding-top: 1rem;
|
||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
border-top: 1px solid $gray-dark;
|
border-top: 1px solid $gray-dark;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-previous a,
|
.nav-previous a,
|
||||||
.nav-next a {
|
.nav-next a,
|
||||||
|
.paged-navigation a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: $gray-dark;
|
color: $gray-dark;
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue