Skip to content

Instantly share code, notes, and snippets.

@gicolek
Created October 11, 2012 23:16
Show Gist options
  • Save gicolek/3876243 to your computer and use it in GitHub Desktop.
Save gicolek/3876243 to your computer and use it in GitHub Desktop.
Pagination eith WP_QUERY
<?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' => '&laquo; Previous',
'next_text' => 'Next &raquo;',
'type' => 'list',
) );
?>
<div class="pagination">
<ul>
<?php echo $pagination; ?>
</ul>
</div>
<!-- ####################################################################################################### -->
<?php
}
@rainb3rry
Copy link

Thanks for your share :)

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