Skip to content

Instantly share code, notes, and snippets.

@fauzanmy
Last active November 3, 2021 15:38
Show Gist options
  • Save fauzanmy/a7d3852d1c9907d3ae8957e21c672aa9 to your computer and use it in GitHub Desktop.
Save fauzanmy/a7d3852d1c9907d3ae8957e21c672aa9 to your computer and use it in GitHub Desktop.
<?php
/**
* The template for displaying page pagination.
*
* @package WordPress
* @subpackage Pehthemepress
*
*/
?>
<?php
// insert paginate data to $paged variable
// return value type to array
$paged = paginate_links( array(
'type' => 'array',
'prev_next' => false // disable
));
if ( $paged ) :
// Replace class
$paged = str_replace('page-numbers', 'page-link', $paged);
// Start ul container
echo '<ul class="pagination">';
// get_previous_posts_link will return a string
$previous = get_next_posts_link();
// get_next_posts_link will return a string
$next = get_next_posts_link();
if ( $previous ) {
echo '<li class="page-item">' . $previous . '</li>';
}
// Print page number
echo '<li class="page-item">';
echo join('</li><li class="page-item">', $paged);
echo '</li>';
if ( $next ) {
echo '<li class="page-item">' . $next . '</li>';
}
echo '</ul>'; // end ul container
endif;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment