Created
July 21, 2012 06:36
-
-
Save claudiosanches/3154862 to your computer and use it in GitHub Desktop.
Wordpress pagination
This file contains hidden or 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
<?php | |
/** | |
* Pagination. | |
*/ | |
function dfw_pagination() { | |
global $wp_query; | |
$total_pages = $wp_query->max_num_pages; | |
if ($total_pages > 1) { | |
$current_page = max( 1, get_query_var( 'paged' ) ); | |
$pagination = '<div class="page-nav">'; | |
$pagination .= paginate_links( array( | |
'base' => get_pagenum_link(1) . '%_%', | |
'format' => '/page/%#%', | |
'current' => $current_page, | |
'total' => $total_pages, | |
'show_all' => false, // Show all items | |
'end_size' => 1, // Total of items displayed for the last few pages | |
'mid_size' => 2, // Total of items that will show along with the current page. | |
'prev_text' => __( '« Anterior', 'dfwtheme' ), | |
'next_text' => __( 'Próximo »', 'dfwtheme'), | |
)); | |
$pagination .= '</div>'; | |
// prevents duplicate bars in the middle of the url | |
$html = str_replace( '//page/', '/page/', $pagination ); | |
echo $html; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment