Skip to content

Instantly share code, notes, and snippets.

@stefthoen
Created November 29, 2012 14:29
Show Gist options
  • Save stefthoen/4169443 to your computer and use it in GitHub Desktop.
Save stefthoen/4169443 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(); ?>
@ziaulrehman40
Copy link

If you add some explanation about customizing the format that would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment