diff --git a/src/php/archive.php b/src/php/archive.php index f45b7b5..4c9474a 100644 --- a/src/php/archive.php +++ b/src/php/archive.php @@ -29,7 +29,7 @@ $context['title'] = single_tag_title( '', false ); } elseif ( is_category() ) { $context['title'] = single_cat_title( '', false ); - array_unshift( $templates, 'archive-' . get_query_var( 'cat' ) . '.twig' ); + array_unshift( $templates, 'archive-' . get_queried_object()->slug . '.twig' ); } elseif ( is_post_type_archive() ) { $context['title'] = post_type_archive_title( '', false ); array_unshift( $templates, 'archive-' . get_post_type() . '.twig' ); diff --git a/src/php/functions.php b/src/php/functions.php index 44c4d7d..6315522 100644 --- a/src/php/functions.php +++ b/src/php/functions.php @@ -123,3 +123,18 @@ function filter_password_protected_posts( $query ) { return $query; } add_filter( 'pre_get_posts', 'filter_password_protected_posts' ); + +/** + * Normalize queries for paginated archive pages to support custom permalink structures. + * + * @param array $query_string - The incoming query string to be normalized. + */ +function normalize_pagination_query_strings( $query_string ) { + if ( isset( $query_string['name'] ) && 'page' === $query_string['name'] && isset( $query_string['page'] ) ) { + unset( $query_string['name'] ); + $query_string['paged'] = $query_string['page']; + } + + return $query_string; +} +add_filter( 'request', 'normalize_pagination_query_strings' );