Created
November 29, 2012 14:29
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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
If you add some explanation about customizing the format that would be helpful.