fixed category pagination.

This commit is contained in:
CBS Information System 2021-01-15 18:40:21 +09:00
parent 993312fc3a
commit e33e226983

View File

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