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');