From d060d3abfbac27c58bf38977a98edb355f14c73c Mon Sep 17 00:00:00 2001 From: Stefan Bohacek Date: Thu, 16 Jul 2020 17:46:05 -0400 Subject: [PATCH] Fixed pagination. --- functions.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/functions.php b/functions.php index c4f5ac0..59d3898 100644 --- a/functions.php +++ b/functions.php @@ -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' ) ), @@ -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 = ''; - return $pagination; + if ( $echo ) { + echo $pagination; + } else { + return $pagination; + } }