Skip to content

Instantly share code, notes, and snippets.

@rajibdpi
Forked from stefthoen/wp-pagination.php
Created July 15, 2018 03:50
Show Gist options
  • Save rajibdpi/b4a6230711de233b32976c82f87b27f7 to your computer and use it in GitHub Desktop.
Save rajibdpi/b4a6230711de233b32976c82f87b27f7 to your computer and use it in GitHub Desktop.
Adds pagination to WordPress without a plugin (taken from HTML5-Blank-WordPress-Theme)
// Add to functions.php
// Pagination for paged posts, Page 1, Page 2, Page 3, with Next and Previous Links, No plugin
function html5wp_pagination()
{
global $wp_query;
$big = 999999999;
echo paginate_links(array(
'base' => str_replace($big, '%#%', get_pagenum_link($big)),
'format' => '?paged=%#%',
'current' => max(1, get_query_var('paged')),
'total' => $wp_query->max_num_pages
));
}
add_action('init', 'html5wp_pagination'); // Add our HTML5 Pagination
// Add to index.php
<?php html5wp_pagination(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment