Skip to content

Fix: max_num_pages becomes negative when posts_per_page is -1 - #4336

Merged
felipeelia merged 2 commits into
developfrom
fix/4334
Jul 23, 2026
Merged

Fix: max_num_pages becomes negative when posts_per_page is -1#4336
felipeelia merged 2 commits into
developfrom
fix/4334

Conversation

@burhandodhy

Copy link
Copy Markdown
Contributor

Description of the Change

When running a WP_Query posts_per_page => -1, ElasticPress was calculating max_num_pages as ceil( found_posts / -1 ), producing a negative value (for example, -17 when 17 posts were found). WordPress core treats posts_per_page => -1 as "return all posts" and leaves max_num_pages at 0 because pagination does not apply.

Closes #4334

How to test the Change

Changelog Entry

Fixed - max_num_pages becomes negative when posts_per_page is -1

Credits

Props @burhandodhy @dmitrijCraq

Checklist:

@burhandodhy burhandodhy added this to the 5.3.4 milestone Jul 7, 2026
@felipeelia
felipeelia merged commit 23ca7f6 into develop Jul 23, 2026
38 checks passed
@felipeelia
felipeelia deleted the fix/4334 branch July 23, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: WP_Query::max_num_pages becomes negative when using ep_integrate

2 participants