Skip to content

Instantly share code, notes, and snippets.

@acerspyro
Created December 30, 2019 20:58
Show Gist options
  • Save acerspyro/ca0a4ef48b0d32bbf8a2b8cbd3eef722 to your computer and use it in GitHub Desktop.
Save acerspyro/ca0a4ef48b0d32bbf8a2b8cbd3eef722 to your computer and use it in GitHub Desktop.
Bootstrap 4 navigation part for WordPress (loosely based on https://gist.github.com/mtx-z/f95af6cc6fb562eb1a1540ca715ed928)
<nav aria-label="pagination">
<?php
global $wp_query;
$entries = paginate_links([
'base' => get_pagenum_link(1) . '%_%',
'format' => '?paged=%#%',
'total' => $wp_query->max_num_pages,
'current' => max( 1, get_query_var('paged') ),
'show_all' => false,
'type' => 'array',
'end_size' => 2,
'mid_size' => 1,
'prev_next' => true,
'prev_text' => '<b>-</b>',
'next_text' => '<b>+</b>',
'add_args' => false,
'add_fragment' => '',
]);
if (is_array($entries))
{
?><ul class="pagination"><?php
foreach ($entries as $entry)
{?>
<li class="page-item<?=(!strpos($entry, 'current') ? '' : ' active')?>">
<?=str_replace('page-numbers', 'page-link', $entry)?>
</li><?php
}
?></ul><?php
}
?>
</nav>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment