Skip to content

Run the full query generator on inherited queries (archive query inheritance) - #176

Open
ryanwelcher wants to merge 7 commits into
trunkfrom
feature/archive-query-inheritance
Open

ryanwelcher wants to merge 7 commits into
trunkfrom
feature/archive-query-inheritance

Conversation

@ryanwelcher

Copy link
Copy Markdown
Owner

What

Inherited Query Loop queries (query.inherit: true) now run the full Query_Params_Generator, so the advanced controls — meta queries, taxonomy queries, date queries, multi-property ordering, caching, and more — layer on top of the archive's own query instead of being silently ignored. The editor exposes the advanced control groups in inherit mode, minus the controls that would override the archive context (additional_post_types, include_posts, exclude_current_post).

Fixes the recurring taxonomy-archive complaint, most recently: https://wordpress.org/support/topic/aql-in-taxonomy-archive/ — a taxonomy archive template can now keep its term filtering while sorting by a meta value.

How

  • PHP (includes/query-loop.php + new Query_Params_Generator::get_inherited_query_args()): the inherit branch of pre_render_block runs the generator over $wp_query->query_vars and merges, instead of hand-copying perPage/order/orderBy. Stale context-overriding attributes (include_posts, multiple_posts, exclude_current) saved before a block was switched to inherit are stripped server-side. aql_query_vars keeps its signature; with $inherited = true it now receives the fully processed args (documented in extending-aql.md).
  • Editor (src/variations/controls.js): inherit mode renders the same control groups as custom mode, gated by a filtered allowedControls list, plus an info notice that archive previews can't reflect the specific term being viewed. Two stale !inherit gates in the order controls were lifted.
  • Tests: 7 new PHPUnit tests for the inherited-args merge (context survival, legacy perPage/order/orderBy equivalence, id → ID normalization, no leakage of stripped params); new Playwright spec covering term filtering + meta ordering, archive pagination, and the inherit-mode editor panels, with blueprint seeding designed so meta order is provably distinct from date order.
  • Docs: extending-aql.md and both readmes, including a documented limitation — with inherit on, a block Items-per-page lower than Settings → Reading can 404 deeper archive pages because core evaluates main-query pagination before the block runs.

Includes a merge of latest trunk (5.0.0 release prep); version references follow suit.

Testing

  • npm run test:unit: 173/173 passing
  • npm run test:e2e: 33/33 passing (includes the 3 new inherited-query tests)
  • npm run lint:php, npm run build: clean

🤖 Generated with Claude Code

https://claude.ai/code/session_01C2rJj83EMLAfKhtwLCGxdP

ryanwelcher and others added 7 commits August 31, 2026 11:46
Replace the hand-merge of three keys (perPage/order/orderBy) with the
full Query_Params_Generator pipeline, enabling all AQL traits to work
on inherited queries. The aql_query_vars filter now receives fully
processed args when inherit=true, not just hardcoded values.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C2rJj83EMLAfKhtwLCGxdP
Add blueprint seeding for a category archive with meta-ordered inherited
AQL queries (filtering, ordering, pagination) and an editor spec covering
the inherit-mode advanced control panels.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C2rJj83EMLAfKhtwLCGxdP
As of version 4.5.0, inherited queries now support the full set of
advanced controls (meta queries, tax queries, date queries, and ordering)
on top of an archive template's query. Document the richer payload in the
aql_query_vars filter and note the limitation regarding Items per page
pagination on deeper archive pages.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C2rJj83EMLAfKhtwLCGxdP
The inherit branch of pre_render_block ran the full Query_Params_Generator
over a block_query attribute that could still carry include_posts,
multiple_posts, or exclude_current from before the block was switched to
inherit. include_posts/multiple_posts corrupt the archive's post__in /
post_type, and exclude_current falls back to get_queried_object_id(),
which on a taxonomy archive returns a term ID, not a post ID, causing an
arbitrary post to be excluded. Unset the three params before generating
inherited query args, and hide the "Exclude current post" control in the
editor's inherit mode (join additional_post_types/include_posts, which
were already hidden). Also fixes a stray 4th @PARAM line on the
aql_query_vars docblock in the same file, and corrects/expands the
extending-aql.md docs: the old $inherited payload always received the
full inherited main-query vars (only posts_per_page/order/orderby from
the block were layered on top, not the other way around), and notes that
AQL caching on an inherited search template creates a transient per
unique search string/page.

Adds two generator-level unit tests mirroring the unset contract, since
query-loop.php can't be loaded by PHPUnit.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C2rJj83EMLAfKhtwLCGxdP
Resolves the readme.txt changelog conflict (trunk renamed the unreleased
block to 5.0.0) and relabels this branch's 4.5.0 references to 5.0.0 to
match the release prep on trunk.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C2rJj83EMLAfKhtwLCGxdP
@ryanwelcher
ryanwelcher requested a lite review from Copilot August 31, 2026 17:52
@ryanwelcher ryanwelcher self-assigned this Aug 31, 2026
@ryanwelcher ryanwelcher added the enhancement New feature or request label Aug 31, 2026
@ryanwelcher ryanwelcher added this to the 5.1 milestone Aug 31, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It changes main-query inheritance behavior across PHP and editor UI with broad runtime impact, so a final human review is warranted despite strong test coverage.

Pull request overview

This PR extends Advanced Query Loop’s inherited Query Loop behavior (query.inherit: true) so inherited (archive) queries are processed through the full Query_Params_Generator, allowing AQL’s advanced filters and ordering to layer on top of the archive’s existing context instead of being ignored.

Changes:

  • Add Query_Params_Generator::get_inherited_query_args() and update the inherit branch in pre_render_block to generate + merge full inherited args (and strip stale context-overriding block params).
  • Update editor inherit-mode UI to expose the advanced AQL control groups (with a reduced allowed-controls set) and remove “inherit-only” gating in ordering controls.
  • Add PHPUnit + Playwright coverage plus blueprint seeding to verify archive term filtering + meta ordering + pagination, and document inherit-mode limitations/behavior.
File summaries
File Description
tests/unit/Inherited_Query_Args_Tests.php Adds unit tests validating inherited-query arg merging, normalization, and prevention of context leakage.
tests/e2e/tests/inherited-query.spec.ts Adds E2E coverage for archive term filtering + meta ordering + pagination and for inherit-mode editor panels.
src/variations/controls.js Exposes advanced panels in inherit mode while filtering out context-overriding controls; adds an editor-preview limitation notice.
src/groups/order.js Enables secondary sort UI in inherit mode (removes previous inherit gating).
src/components/post-order-controls.js Enables meta-key ordering UI in inherit mode (removes previous inherit gating).
readme.txt Documents full inherit-mode support plus the perPage vs Reading setting 404 limitation.
readme.md Adds 5.0.0 changelog entry describing inherit-mode behavior and limitation.
includes/query-loop.php Runs the full query generator for inherited queries, strips stale override params, and passes processed args to aql_query_vars.
includes/Query_Params_Generator.php Introduces get_inherited_query_args() to merge inherited vars + core perPage/order + trait-generated args.
extending-aql.md Documents updated inherited-mode aql_query_vars behavior and notes caching/transient implications.
_blueprints/e2e-blueprint.json Seeds categories + meta and adjusts Reading pagination for deterministic inherited-archive E2E coverage.
Review details
  • Files reviewed: 11/11 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants