Skip to content

Commit

Permalink
Fixed pagination.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanbohacek committed Jul 16, 2020
1 parent da87e42 commit d060d3a
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,13 @@ function my_remove_recent_comments_style(){
}

// Pagination for paged posts, Page 1, Page 2, Page 3, with Next and Previous Links, No plugin
function botwiki_site_pagination(){
global $wp_query;
function botwiki_site_pagination( \WP_Query $wp_query = null, $echo = true, $params = [] ){
if ( null === $wp_query ) {
global $wp_query;
}

$big = 999999999;
$pages = paginate_links(array(
$pages = paginate_links( array_merge( array(
'base' => str_replace($big, '%#%', get_pagenum_link($big)),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var( 'paged' ) ),
Expand All @@ -324,14 +327,7 @@ function botwiki_site_pagination(){
'next_text' => __( 'Next »' ),
'add_args' => $add_args,
'add_fragment' => ''


// 'base' => str_replace($big, '%#%', get_pagenum_link($big)),
// // 'format' => '?paged=%#%',
// 'format' => '/page/%#%',
// 'current' => max(1, get_query_var( 'paged' )),
// 'total' => $wp_query->max_num_pages
));
), $params );

$pagination = '<div class="pagination"><ul class="pagination">';
foreach ( $pages as $page ) {
Expand All @@ -340,7 +336,11 @@ function botwiki_site_pagination(){

$pagination .= '</ul></div>';

return $pagination;
if ( $echo ) {
echo $pagination;
} else {
return $pagination;
}

}

Expand Down

0 comments on commit d060d3a

Please sign in to comment.