Skip to content

Deduplicate queryId for query loop blocks#10

Merged
roborourke merged 1 commit intomainfrom
fix/deduplicate-query-ids
Feb 4, 2026
Merged

Deduplicate queryId for query loop blocks#10
roborourke merged 1 commit intomainfrom
fix/deduplicate-query-ids

Conversation

@roborourke
Copy link
Collaborator

Summary

  • Ensures each query loop block has a unique queryId in both the editor and during server-side rendering, fixing a WordPress core issue where duplicating a query loop copies the queryId without deduplication
  • Editor: assigns unique queryId from post ID + block index via a BlockEdit HOC
  • Server-side: tracks used queryIds and only overrides duplicates, preserving original values for interoperability with other plugins. Uses dynamic render_block_context filters with depth tracking for correct nested query block handling
  • Adds E2E tests verifying uniqueness in the editor (3 duplicated blocks) and on the front end (exclude displayed posts works correctly across duplicated loops)

Test plan

  • Add a query loop block to a page, duplicate it 2-3 times, verify each has a unique queryId in the block attributes
  • Enable "Exclude already displayed posts" on duplicated query loops, publish, and verify no post appears in multiple loops
  • Verify existing query loops with already-unique IDs are not modified
  • Run npm run test:e2e — all 12 tests pass

🤖 Generated with Claude Code

WordPress core does not deduplicate queryId when query loop blocks are
duplicated, which breaks features that rely on unique IDs (e.g. exclude
displayed posts, independent pagination).

Editor: adds a HOC that assigns each query block a unique queryId derived
from the current post ID and the block's index among all query blocks.

Server-side: tracks used queryIds and only overrides duplicates, preserving
original values for interoperability. Uses dynamic render_block_context
filters with depth tracking to correctly handle nested query blocks.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@roborourke roborourke requested a review from tomjn February 4, 2026 13:09
@github-actions
Copy link

github-actions bot commented Feb 4, 2026

Playwright test results

passed  12 passed

Details

stats  12 tests across 4 suites
duration  50.7 seconds
commit  7529017

@roborourke roborourke merged commit 6d0107b into main Feb 4, 2026
1 check passed
@roborourke roborourke deleted the fix/deduplicate-query-ids branch February 4, 2026 13:30
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