Created
June 27, 2013 23:26
-
-
Save iammahmudur/5881276 to your computer and use it in GitHub Desktop.
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
/** | |
* Pagination function | |
* | |
* @param int $max_num_pages | |
*/ | |
function my_pagination( $max_num_pages = 0 ) { | |
// get total number of pages | |
global $wp_query; | |
$max_num_pages = ( $max_num_pages > 0 ) ? $max_num_pages : $wp_query->max_num_pages; | |
// only bother with the rest if we have more than 1 page! | |
if ( $max_num_pages > 1) { | |
//Load more button | |
?> | |
<div class="pagination clearfix <?php echo (get_option(SHORTNAME . "_infinite")) ? 'paginationhide' : ''; ?>"> | |
<div class='pagination_line'></div> | |
<?php | |
if (get_option(SHORTNAME . "_infinite")) { | |
echo "<a href='#' id='load' class='load_more'><span></span>Load more</a>"; | |
} | |
// get the current page | |
if (get_query_var('paged')) { | |
$current_page = get_query_var('paged'); | |
} else if (get_query_var('page')) { | |
$current_page = get_query_var('page'); | |
} else { | |
$current_page = 1; | |
} | |
// structure of format depends on whether using pretty permalinks | |
$permalink_structure = get_option('permalink_structure'); | |
if (empty($permalink_structure)) { | |
if (is_front_page()) { | |
$format = '?paged=%#%'; | |
} else { | |
$format = '&paged=%#%'; | |
} | |
} else { | |
$format = 'page/%#%/'; | |
} | |
echo paginate_links( | |
array( | |
'base' => get_pagenum_link(1) . '%_%', | |
'format' => $format, | |
'current' => $current_page, | |
'total' => $max_num_pages, | |
'mid_size' => 10, | |
'type' => 'list' | |
) | |
); | |
?> | |
</div> | |
<?php | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment