From a5d2cd1e53403083471d799d3f3e95e582058ced Mon Sep 17 00:00:00 2001 From: Benjamin Turner Date: Wed, 4 Nov 2026 12:17:04 -0700 Subject: [PATCH 01/15] Tests: Cover the zero `max_num_pages` fallback in `paginate_links()`. Add a test that `paginate_links()` returns null when the global query reports zero total pages, matching its behavior for a single total page. See #65817. --- tests/phpunit/tests/general/paginateLinks.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/phpunit/tests/general/paginateLinks.php b/tests/phpunit/tests/general/paginateLinks.php index a0f91de60c1c4..c907296d99b68 100644 --- a/tests/phpunit/tests/general/paginateLinks.php +++ b/tests/phpunit/tests/general/paginateLinks.php @@ -563,4 +563,19 @@ public static function data_query_strings(): array { 'multi query vars' => array( 'foo=bar&pen=pencil' ), ); } + + /** + * Ensures `paginate_links()` returns null when the global query reports + * zero total pages, matching its behavior for a single total page. + * + * @ticket 65817 + */ + public function test_paginate_links_falls_back_to_global_query_with_zero_max_num_pages() { + global $wp_query; + + // `WP_Query::$max_num_pages` defaults to, and can be left at, `0` -- never `null`. + $wp_query->max_num_pages = 0; + + $this->assertNull( paginate_links() ); + } } From 07322e2fd5e30ff51e3621e4767c67e1807241da Mon Sep 17 00:00:00 2001 From: Benjamin Turner Date: Wed, 4 Nov 2026 12:19:59 -0700 Subject: [PATCH 02/15] Code Quality: Fix the `nullCoalesce.property` PHPStan error and remove the baseline. `WP_Query::$max_num_pages` defaults to `0` and is never `null`, so the `?? 1` fallback in `paginate_links()` never ran. Use `?:` instead, which also falls back for `0`, and retire the now-empty baseline. See #65817. --- phpstan.neon.dist | 1 - src/wp-includes/general-template.php | 2 +- .../baselines/nullCoalesce.property.neon | 25 ------------------- 3 files changed, 1 insertion(+), 27 deletions(-) delete mode 100644 tests/phpstan/baselines/nullCoalesce.property.neon diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 655bb9bbc807c..6f109ebfb6451 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -42,7 +42,6 @@ includes: - tests/phpstan/baselines/method.childParameterType.neon - tests/phpstan/baselines/method.unused.neon - tests/phpstan/baselines/notIdentical.alwaysTrue.neon - - tests/phpstan/baselines/nullCoalesce.property.neon - tests/phpstan/baselines/offsetAccess.nonOffsetAccessible.neon - tests/phpstan/baselines/offsetAccess.notFound.neon - tests/phpstan/baselines/offsetAssign.valueType.neon diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index eb6e185f5b49d..92a79ab16f706 100644 --- a/src/wp-includes/general-template.php +++ b/src/wp-includes/general-template.php @@ -4983,7 +4983,7 @@ function paginate_links( $args = '' ) { $url_parts = explode( '?', $pagenum_link ); // Get max pages and current page out of the current query, if available. - $total = $wp_query->max_num_pages ?? 1; + $total = $wp_query->max_num_pages ?: 1; $current = get_query_var( 'paged' ) ? (int) get_query_var( 'paged' ) : 1; /* diff --git a/tests/phpstan/baselines/nullCoalesce.property.neon b/tests/phpstan/baselines/nullCoalesce.property.neon deleted file mode 100644 index 0085e07d9614f..0000000000000 --- a/tests/phpstan/baselines/nullCoalesce.property.neon +++ /dev/null @@ -1,25 +0,0 @@ -# PHPStan baseline for the `nullCoalesce.property` errors in WordPress core. -# -# https://phpstan.org/error-identifiers/nullCoalesce.property -# -# Each entry is scoped to a single file and carries an exact occurrence count, -# so that a new instance is reported as a new error rather than being absorbed -# silently. Fixing an occurrence therefore means decrementing or removing its -# entry here as part of the same change. -# -# The goal is to empty this file and delete it, along with the `includes` entry -# for it in phpstan.neon.dist. -# -# Generated by `composer phpstan:baselines`. Do not edit by hand; regenerate with -# -# composer phpstan:baselines -- --identifier=nullCoalesce.property -# -# which reruns the analysis with this file suppressed so the errors surface again. - -parameters: - ignoreErrors: - - - message: '#^Property WP_Query\:\:\$max_num_pages \(int\) on left side of \?\? is not nullable\.$#' - identifier: nullCoalesce.property - count: 1 - path: ../../../src/wp-includes/general-template.php From 6014bc4fb8d0eefa38ecd0aec3ed51f49d2519e4 Mon Sep 17 00:00:00 2001 From: Benjamin Turner Date: Wed, 4 Nov 2026 14:02:43 -0700 Subject: [PATCH 03/15] Fix coding standards: use a full ternary instead of the disallowed short ternary. WordPress Coding Standards disallows `?:` (Universal.Operators.DisallowShortTernary). Use the `$x ? $x : $y` form already used elsewhere in core for a falsy fallback. See #65817. --- src/wp-includes/general-template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index 92a79ab16f706..bd0ccb87b0a33 100644 --- a/src/wp-includes/general-template.php +++ b/src/wp-includes/general-template.php @@ -4983,7 +4983,7 @@ function paginate_links( $args = '' ) { $url_parts = explode( '?', $pagenum_link ); // Get max pages and current page out of the current query, if available. - $total = $wp_query->max_num_pages ?: 1; + $total = $wp_query->max_num_pages ? $wp_query->max_num_pages : 1; $current = get_query_var( 'paged' ) ? (int) get_query_var( 'paged' ) : 1; /* From da9ea557addd1d400c4909237f2ffce4150f2a7c Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 4 Nov 2026 15:01:33 -0700 Subject: [PATCH 04/15] Narrow type for max_num_pages --- src/wp-includes/class-wp-query.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wp-includes/class-wp-query.php b/src/wp-includes/class-wp-query.php index 88981421ff937..9ab8aef960c4f 100644 --- a/src/wp-includes/class-wp-query.php +++ b/src/wp-includes/class-wp-query.php @@ -186,6 +186,7 @@ class WP_Query { * * @since 2.1.0 * @var int + * @phpstan-var int<0, max> */ public $max_num_pages = 0; From e79fca3044bfe2560c33fea738a71f850646516c Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 4 Nov 2026 15:02:10 -0700 Subject: [PATCH 05/15] Add missing global type --- tests/phpunit/tests/general/paginateLinks.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/phpunit/tests/general/paginateLinks.php b/tests/phpunit/tests/general/paginateLinks.php index c907296d99b68..131b560e8fd7a 100644 --- a/tests/phpunit/tests/general/paginateLinks.php +++ b/tests/phpunit/tests/general/paginateLinks.php @@ -569,6 +569,8 @@ public static function data_query_strings(): array { * zero total pages, matching its behavior for a single total page. * * @ticket 65817 + * + * @global WP_Query $wp_query Global query. */ public function test_paginate_links_falls_back_to_global_query_with_zero_max_num_pages() { global $wp_query; From 10384aade4d84960ed7b0b9f37e94c520fd99823 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 4 Nov 2026 15:14:50 -0700 Subject: [PATCH 06/15] Guard global query before reading max_num_pages Replacing `?? 1` with a plain ternary dropped the null-safe read of `$wp_query`, so `paginate_links()` would warn when the global query is not set (e.g. before `wp()` runs, or after a plugin unsets it). Check `$wp_query instanceof WP_Query` instead, which keeps the fallback to 1 and still satisfies PHPStan. Also cast to int and clamp to at least 1. Many plugins assign `ceil(...)` to `max_num_pages` without a cast, which yields a float, and a `found_posts` filter can drive the computed value negative. Co-Authored-By: Claude Opus 5.5 (medium effort) Claude-Code-Session-Id: 92a8904b-c6d4-4ac3-8ba5-7d8209aed336 --- src/wp-includes/general-template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index bd0ccb87b0a33..f3f3f96e29f88 100644 --- a/src/wp-includes/general-template.php +++ b/src/wp-includes/general-template.php @@ -4983,7 +4983,7 @@ function paginate_links( $args = '' ) { $url_parts = explode( '?', $pagenum_link ); // Get max pages and current page out of the current query, if available. - $total = $wp_query->max_num_pages ? $wp_query->max_num_pages : 1; + $total = $wp_query instanceof WP_Query ? max( 1, (int) $wp_query->max_num_pages ) : 1; $current = get_query_var( 'paged' ) ? (int) get_query_var( 'paged' ) : 1; /* From 17abb1f816843a1202ba6aeb385b91d6603a71d5 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 4 Nov 2026 15:25:40 -0700 Subject: [PATCH 07/15] Clamp computed max_num_pages to a non-negative int MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `int<0, max>` type on `WP_Query::$max_num_pages` exposed that the computed value can go negative: a `found_posts` filter may return a negative count, and a filter-injected `LIMIT` on a `posts_per_page = -1` query divides by -1. Clamp the result with `max( 0, … )` so the property holds the type it declares. Also cast `posts_per_page` to int in the division. It is already an int by this point, so behavior is unchanged, but the query vars array is otherwise typed as mixed. Co-Authored-By: Claude Opus 5.5 (medium effort) Claude-Code-Session-Id: 92a8904b-c6d4-4ac3-8ba5-7d8209aed336 --- src/wp-includes/class-wp-query.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-query.php b/src/wp-includes/class-wp-query.php index 9ab8aef960c4f..2b593c0addd6b 100644 --- a/src/wp-includes/class-wp-query.php +++ b/src/wp-includes/class-wp-query.php @@ -3733,7 +3733,7 @@ private function set_found_posts( $query_vars, $limits ) { $this->found_posts = (int) apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) ); if ( ! empty( $limits ) ) { - $this->max_num_pages = (int) ceil( $this->found_posts / $query_vars['posts_per_page'] ); + $this->max_num_pages = max( 0, (int) ceil( $this->found_posts / (int) $query_vars['posts_per_page'] ) ); } } From ce5bf98acaa9489ac3d2595aa4c53279aa4683c5 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 4 Nov 2026 15:29:02 -0700 Subject: [PATCH 08/15] Drop the instanceof guard from paginate_links() The guard did not make `paginate_links()` tolerate a missing global query: the next line calls `get_query_var()`, which dereferences `$wp_query` unconditionally, so a null global fatals there either way. Keep only the int cast and the clamp to at least 1. Co-Authored-By: Claude Opus 5.5 (medium effort) Claude-Code-Session-Id: 92a8904b-c6d4-4ac3-8ba5-7d8209aed336 --- src/wp-includes/general-template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index f3f3f96e29f88..9d526952030e1 100644 --- a/src/wp-includes/general-template.php +++ b/src/wp-includes/general-template.php @@ -4983,7 +4983,7 @@ function paginate_links( $args = '' ) { $url_parts = explode( '?', $pagenum_link ); // Get max pages and current page out of the current query, if available. - $total = $wp_query instanceof WP_Query ? max( 1, (int) $wp_query->max_num_pages ) : 1; + $total = max( 1, (int) $wp_query->max_num_pages ); $current = get_query_var( 'paged' ) ? (int) get_query_var( 'paged' ) : 1; /* From 3ce207a649dd3dfbbd2dde8164630ab00e9758f3 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 4 Nov 2026 15:29:32 -0700 Subject: [PATCH 09/15] Test that max_num_pages is clamped for a negative found_posts A `found_posts` filter returning -5 with `posts_per_page` of 2 used to yield a `max_num_pages` of -2. Assert it is now clamped to 0, while the filtered `found_posts` value itself is kept. Co-Authored-By: Claude Opus 5.5 (medium effort) Claude-Code-Session-Id: 92a8904b-c6d4-4ac3-8ba5-7d8209aed336 --- tests/phpunit/tests/query/noFoundRows.php | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/phpunit/tests/query/noFoundRows.php b/tests/phpunit/tests/query/noFoundRows.php index 7b4f66a416030..3877762ef5b6d 100644 --- a/tests/phpunit/tests/query/noFoundRows.php +++ b/tests/phpunit/tests/query/noFoundRows.php @@ -102,4 +102,31 @@ public function test_no_found_rows_default_with_postsperpage_minus1() { $this->assertStringNotContainsString( 'SQL_CALC_FOUND_ROWS', $q->request ); $this->assertSame( 1, $q->found_posts ); } + + /** + * Ensures {@see WP_Query::$max_num_pages} is not negative when the + * {@see 'found_posts'} filter returns a negative count. + * + * @ticket 65817 + */ + public function test_max_num_pages_is_not_negative_when_found_posts_is_filtered_negative() { + self::factory()->post->create_many( 3 ); + + add_filter( + 'found_posts', + static function (): int { + return -5; + } + ); + + $q = new WP_Query( + array( + 'post_type' => 'post', + 'posts_per_page' => 2, + ) + ); + + $this->assertSame( -5, $q->found_posts, 'Expected the filtered found_posts value to be kept.' ); + $this->assertSame( 0, $q->max_num_pages, 'Expected max_num_pages to be clamped to zero.' ); + } } From d4dc8e51214eed69ef09d137e760978a39af8e06 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 4 Nov 2026 15:48:27 -0700 Subject: [PATCH 10/15] Update baseline ] --- tests/phpstan/baselines/isset.property.neon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpstan/baselines/isset.property.neon b/tests/phpstan/baselines/isset.property.neon index 063b443d92227..6252f11549364 100644 --- a/tests/phpstan/baselines/isset.property.neon +++ b/tests/phpstan/baselines/isset.property.neon @@ -179,7 +179,7 @@ parameters: count: 1 path: ../../../src/wp-includes/rest-api/endpoints/class-wp-rest-font-families-controller.php - - message: '#^Property WP_Query\:\:\$max_num_pages \(int\) in isset\(\) is not nullable\.$#' + message: '#^Property WP_Query\:\:\$max_num_pages \(int\<0, max\>\) in isset\(\) is not nullable\.$#' identifier: isset.property count: 1 path: ../../../src/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php From b429cda25db0d3b048e09da1c55f8935eb1391bd Mon Sep 17 00:00:00 2001 From: Benjamin Turner Date: Wed, 4 Nov 2026 15:55:21 -0700 Subject: [PATCH 11/15] Drop the pointless isset() check in WP_Sitemaps_Posts::get_max_num_pages(). `$query` is always a fresh `WP_Query` instance, so `max_num_pages` is always set -- the `isset()` branch was dead code, and the fallback to `1` could never run. Remove it and retire the now-unmatched baseline entry, rather than just patching the baseline regex to match the narrower `int<0, max>` type. See #65817. --- .../sitemaps/providers/class-wp-sitemaps-posts.php | 2 +- tests/phpstan/baselines/isset.property.neon | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php b/src/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php index c96b12c7e25f6..c1545c26b9105 100644 --- a/src/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php +++ b/src/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php @@ -209,7 +209,7 @@ public function get_max_num_pages( $object_subtype = '' ) { $query = new WP_Query( $args ); $min_num_pages = ( 'page' === $post_type && 'posts' === get_option( 'show_on_front' ) ) ? 1 : 0; - return isset( $query->max_num_pages ) ? max( $min_num_pages, $query->max_num_pages ) : 1; + return max( $min_num_pages, $query->max_num_pages ); } /** diff --git a/tests/phpstan/baselines/isset.property.neon b/tests/phpstan/baselines/isset.property.neon index 6252f11549364..5278005df2869 100644 --- a/tests/phpstan/baselines/isset.property.neon +++ b/tests/phpstan/baselines/isset.property.neon @@ -178,11 +178,6 @@ parameters: identifier: isset.property count: 1 path: ../../../src/wp-includes/rest-api/endpoints/class-wp-rest-font-families-controller.php - - - message: '#^Property WP_Query\:\:\$max_num_pages \(int\<0, max\>\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 1 - path: ../../../src/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php - message: '#^Property WP_Site\:\:\$domain \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property From f4c4d575ca168b14f32126e3ba07ca7c5d82cbb1 Mon Sep 17 00:00:00 2001 From: Benjamin Turner Date: Wed, 4 Nov 2026 16:10:52 -0700 Subject: [PATCH 12/15] Tests: Cover the filtered LIMIT on a posts_per_page = -1 query. The PR description calls out a second path to a negative max_num_pages: a `post_limits` filter injecting a non-empty LIMIT clause on a `posts_per_page = -1` query, which otherwise sets `nopaging` and never runs the found-rows calculation at all. Only the negative-found_posts path had a regression test. Verified this new test fails with -3 against the unclamped `(int) ceil(...)` and passes with the max( 0, ... ) clamp. See #65817. --- tests/phpunit/tests/query/noFoundRows.php | 30 +++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/phpunit/tests/query/noFoundRows.php b/tests/phpunit/tests/query/noFoundRows.php index 3877762ef5b6d..befc361067000 100644 --- a/tests/phpunit/tests/query/noFoundRows.php +++ b/tests/phpunit/tests/query/noFoundRows.php @@ -129,4 +129,34 @@ static function (): int { $this->assertSame( -5, $q->found_posts, 'Expected the filtered found_posts value to be kept.' ); $this->assertSame( 0, $q->max_num_pages, 'Expected max_num_pages to be clamped to zero.' ); } + + /** + * Ensures {@see WP_Query::$max_num_pages} is not negative when a + * {@see 'post_limits'} filter injects a non-empty `LIMIT` clause on a + * `posts_per_page = -1` query, which otherwise never runs the found-rows + * calculation and skips the `max_num_pages` division entirely. + * + * @ticket 65817 + */ + public function test_max_num_pages_is_not_negative_when_limits_are_filtered_with_postsperpage_minus1() { + self::factory()->post->create_many( 3 ); + + add_filter( + 'post_limits', + static function (): string { + return 'LIMIT 0, 2'; + } + ); + + $q = new WP_Query( + array( + 'post_type' => 'post', + 'posts_per_page' => -1, + ) + ); + + $this->assertStringContainsString( 'SQL_CALC_FOUND_ROWS', $q->request, 'Expected the filtered LIMIT to trigger the found-rows query.' ); + $this->assertSame( 3, $q->found_posts, 'Expected found_posts to reflect all matching rows.' ); + $this->assertSame( 0, $q->max_num_pages, 'Expected max_num_pages to be clamped to zero.' ); + } } From 3127bb326c9d4d4e3722d1336ee4a3ae636d9bc3 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 4 Nov 2026 17:21:58 -0700 Subject: [PATCH 13/15] Assert that request has been set --- tests/phpunit/tests/query/noFoundRows.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/phpunit/tests/query/noFoundRows.php b/tests/phpunit/tests/query/noFoundRows.php index befc361067000..e9ffcd6581362 100644 --- a/tests/phpunit/tests/query/noFoundRows.php +++ b/tests/phpunit/tests/query/noFoundRows.php @@ -155,6 +155,7 @@ static function (): string { ) ); + $this->assertIsString( $q->request ); $this->assertStringContainsString( 'SQL_CALC_FOUND_ROWS', $q->request, 'Expected the filtered LIMIT to trigger the found-rows query.' ); $this->assertSame( 3, $q->found_posts, 'Expected found_posts to reflect all matching rows.' ); $this->assertSame( 0, $q->max_num_pages, 'Expected max_num_pages to be clamped to zero.' ); From 49bc13fa1f83422bf9c5b52e4873eaf8134dc9b9 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 4 Nov 2026 17:34:08 -0700 Subject: [PATCH 14/15] Drop the zero max_num_pages test for paginate_links() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `paginate_links()` returns null for any total under 2, so the test passed both with and without the `max( 1, … )` clamp and could not catch a regression. The clamp's behavior is covered in `WP_Query` instead. Co-Authored-By: Claude Opus 5.5 (medium effort) Claude-Code-Session-Id: 92a8904b-c6d4-4ac3-8ba5-7d8209aed336 --- tests/phpunit/tests/general/paginateLinks.php | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/tests/phpunit/tests/general/paginateLinks.php b/tests/phpunit/tests/general/paginateLinks.php index 50535ba55f329..fb99e86e0f459 100644 --- a/tests/phpunit/tests/general/paginateLinks.php +++ b/tests/phpunit/tests/general/paginateLinks.php @@ -565,21 +565,4 @@ public static function data_query_strings(): array { 'multi query vars' => array( 'foo=bar&pen=pencil' ), ); } - - /** - * Ensures `paginate_links()` returns null when the global query reports - * zero total pages, matching its behavior for a single total page. - * - * @ticket 65817 - * - * @global WP_Query $wp_query Global query. - */ - public function test_paginate_links_falls_back_to_global_query_with_zero_max_num_pages() { - global $wp_query; - - // `WP_Query::$max_num_pages` defaults to, and can be left at, `0` -- never `null`. - $wp_query->max_num_pages = 0; - - $this->assertNull( paginate_links() ); - } } From 2a5189f627b3f2cff5d37d33725b035019698111 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 4 Nov 2026 17:37:33 -0700 Subject: [PATCH 15/15] Read max_num_pages directly in paginate_links() The `?? 1` fallback, and the `isset()` ternary it replaced, only ever applied to an unset property, which never happens on `WP_Query`. So a `max_num_pages` of 0 always passed through as 0, and clamping the default to at least 1 changed nothing observable: the function returns null for any total under 2. The cast is unnecessary as well, since `$args['total']` is cast to int before it is used. Co-Authored-By: Claude Opus 5.5 (medium effort) Claude-Code-Session-Id: 92a8904b-c6d4-4ac3-8ba5-7d8209aed336 --- src/wp-includes/general-template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index 9d526952030e1..f91680a9ef44c 100644 --- a/src/wp-includes/general-template.php +++ b/src/wp-includes/general-template.php @@ -4983,7 +4983,7 @@ function paginate_links( $args = '' ) { $url_parts = explode( '?', $pagenum_link ); // Get max pages and current page out of the current query, if available. - $total = max( 1, (int) $wp_query->max_num_pages ); + $total = $wp_query->max_num_pages; $current = get_query_var( 'paged' ) ? (int) get_query_var( 'paged' ) : 1; /*