Skip to content

Instantly share code, notes, and snippets.

@annelyse
Created March 28, 2022 09:33
Show Gist options
  • Save annelyse/b51f3760d461f64effd81677bd739c9a to your computer and use it in GitHub Desktop.
Save annelyse/b51f3760d461f64effd81677bd739c9a to your computer and use it in GitHub Desktop.
<?php
global $wp_query;
$currentPage = get_query_var('paged');
$total = $wp_query->max_num_pages;
// si il n'y a pas de page
if( !$currentPage) {
$currentPage = 1;
}
$next = $currentPage + 1;
if( $currentPage == $total ){
$next = $currentPage ;
}
$prev = $currentPage - 1;
if( $currentPage == 1 ){
$currentPage = 1;
}
?>
<div class="pagination pagination-fraction">
<span>Page suivante</span>
<a href="<?php echo get_pagenum_link($prev) ?>"><</a>
<span><?php echo $currentPage; ?></span> /
<span><?php echo $wp_query->max_num_pages ?></span>
<a href="<?php echo get_pagenum_link($next) ?>">></a>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment