From e33e2269837c386b32e7a6a4035f5fca6abb070c Mon Sep 17 00:00:00 2001 From: NIU Administrator Date: Fri, 15 Jan 2021 18:40:21 +0900 Subject: [PATCH] fixed category pagination. --- functions.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/functions.php b/functions.php index 80dff9e..347f67c 100644 --- a/functions.php +++ b/functions.php @@ -204,6 +204,23 @@ function cbsonline_category_year_link($url, $year) return $url; } +add_filter('request', 'cbsonline_fix_category_pagination'); +function cbsonline_fix_category_pagination($query = []) +{ + if (isset($query['category_name']) && isset($query['page'])) { + if (preg_match('/^(?:category\/)?(.+)\/page$/', $query['category_name'], $matches)) { + $query['category_name'] = $matches[1]; + } + $query['category_name'] .= $query['page']; + unset($query['page']); + if (isset($query['p'])) { + $query['paged'] = $query['p']; + unset($query['p']); + } + } + + return $query; +} // support tag cloud for static pages add_action('init', 'cbsonline_add_tag_to_page');