Skip to content

Drop the loop's page parameter when a search runs - #59

Merged
roborourke merged 1 commit into
mainfrom
claude/bug-validation-fixes-07a61k-issue-21
Sep 2, 2026
Merged

Drop the loop's page parameter when a search runs#59
roborourke merged 1 commit into
mainfrom
claude/bug-validation-fixes-07a61k-issue-21

Conversation

@roborourke

@roborourke roborourke commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Fixes #21.

Reproduced

A loop with a search block and pagination, two posts to a page. On /search-pagination/?query-5-page=2 the form action renders as:

<form  action="/search-pagination/?query-5-page=2&query-5-s">

Searching "Alpha" from there navigates to ?query-5-page=2&query-5-s=Alpha — page 2 of a two-result search — and the loop renders empty, while ?query-5-s=Alpha alone returns Alpha One and Alpha Two. Verified on WordPress 6.8.8 and 7.0.4.

Changes

  • inc/namespace.php: render_block_search() removes the loop's page parameter from the form action, alongside the existing /page/N strip. The parameter is named the way core names it (query-{queryId}-page, or query-page with no queryId) so the parameter the pagination block wrote is the one that gets dropped, and page for an inherited query. The taxonomy filter already resets pagination this way.
  • tests/seed.php adds fixture page 5, /search-pagination/: a paginated loop with a search block, two posts to a page.
  • tests/e2e/search-filter.spec.js searches from page 2 and asserts the page parameter is gone and the matches render.

This overlaps #22, which fixes the same bug by rewriting the JS side. Doing it in the action URL keeps the reset next to the other URL building and covers a native form submit with JS disabled too — either is fine by me, closing the older PR in favour of this one is the author's call.

Verification

The new spec fails on main (Received string: …?query-5-page=2&query-5-s=Alpha) and passes with the fix. Full suite: 21 passed on WP 6.8.8 and 7.0.4. composer phpcs clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Lj871x28S1DXjoVm7AB4k5


Generated by Claude Code

Open WordPress Playground Preview

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

Playwright — PHP 8.3 / WP latest

passed  21 passed

Details

stats  21 tests across 4 suites
duration  19.3 seconds
commit  ca0ff97

The search block's form action is built from the current URL, so the
pagination parameter the pagination block wrote is carried into the search.
Searching from page 2 asks for page 2 of the matches, and a term with only
one page of results renders an empty loop over results that do exist.

Remove the loop's page parameter from the action, named as core names it so
the parameter the pagination block wrote is the one that gets dropped. The
taxonomy filter already resets pagination this way.

Reported and first fixed by @samikeijonen in #22, which resets the same
parameter on the JS side.

Props samikeijonen.

Fixes #21

Co-authored-by: Sami Keijonen <1820415+samikeijonen@users.noreply.github.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lj871x28S1DXjoVm7AB4k5
@roborourke
roborourke force-pushed the claude/bug-validation-fixes-07a61k-issue-21 branch from 6196436 to ca0ff97 Compare September 2, 2026 11:39
@roborourke
roborourke marked this pull request as ready for review September 2, 2026 11:39
github-actions Bot added a commit that referenced this pull request Sep 2, 2026
@roborourke
roborourke merged commit 52cc85e into main Sep 2, 2026
7 of 11 checks passed
@roborourke
roborourke deleted the claude/bug-validation-fixes-07a61k-issue-21 branch September 2, 2026 11:49
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.

Search does not work in paginated pages

2 participants