Skip to content

#30631 Prevent duplicate content with nopaging queries - #13232

Draft
skikken wants to merge 2 commits into
WordPress:trunkfrom
skikken:fix/30631-posts-per-page-infinite-pages
Draft

#30631 Prevent duplicate content with nopaging queries#13232
skikken wants to merge 2 commits into
WordPress:trunkfrom
skikken:fix/30631-posts-per-page-infinite-pages

Conversation

@skikken

@skikken skikken commented Aug 22, 2026

Copy link
Copy Markdown
  1. Paging block: new elseif - when nopaging is truthy, not singular, and paged > 1, set $limits = 'LIMIT 0'. The query returns zero rows instead of the full result set on every paginated URL.
  2. set_found_posts(): when $limits is non-empty and nopaging is truthy, max_num_pages = 1 (posts_per_page is -1 there and can't divide the total).

Trac ticket: https://core.trac.wordpress.org/ticket/30631

Use of AI Tools

AI assistance: Yes
Tool(s): Claude
Model(s): Sonnet
Used for: review and test cases


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Setting posts_per_page to -1 via pre_get_posts forced nopaging,
which removed the LIMIT clause entirely. Every paginated URL then
returned the full result set, producing unlimited identical pages
of duplicate content.

Return no posts when a nopaging query requests a page above the
first, mirroring how out-of-bounds pages behave under normal
pagination. found_posts stays accurate via SQL_CALC_FOUND_ROWS
and max_num_pages is clamped to 1.

Closes #30631
@skikken skikken changed the title fix: prevent duplicate content with nopaging queries #30631 Prevent duplicate content with nopaging queries Aug 22, 2026
@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

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.

1 participant