Created
October 11, 2012 23:16
-
-
Save gicolek/3876243 to your computer and use it in GitHub Desktop.
Pagination eith WP_QUERY
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 | |
/** | |
* Generates the user pagination for custom and default queries | |
* | |
* @global object $wp_query | |
* @param object $query used within a custom loop | |
*/ | |
function skeleton_pagination($query = null) { | |
if ( !$query ) { | |
global $wp_query; | |
$query = $wp_query; | |
} | |
$big = 999999999; // need an unlikely integer | |
$pagination = paginate_links( array( | |
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), | |
'format' => '?paged=%#%', | |
'current' => max( 1, get_query_var( 'paged' ) ), | |
'total' => $query->max_num_pages, | |
'prev_text' => '« Previous', | |
'next_text' => 'Next »', | |
'type' => 'list', | |
) ); | |
?> | |
<div class="pagination"> | |
<ul> | |
<?php echo $pagination; ?> | |
</ul> | |
</div> | |
<!-- ####################################################################################################### --> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for your share :)