gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Query Loop block: perPage from custom block pattern is ignored when inserting block via block editor UI

Open JelleTempelman opened this issue 1 year ago • 3 comments

Description

When inserting a Query Loop block on a page using the block editor, and selecting a block pattern, the perPage setting defined in the pattern is ignored, and instead is set to 10.

This only happens when inserting the block via the initial template selection screen. If I click "Change design" and select the same pattern again, the correct perPage is applied.

Step-by-step reproduction instructions

  1. Make sure you have more than 3 posts.
  2. Edit a page in the block editor.
  3. Insert a Query Loop block.
  4. Choose the pattern "List of posts, 1 column" in the initial selection popup. Expected: the query block shows 3 posts. Actual: the query block shows 10 posts.

Now click the block, click “Change design”, select the same custom pattern again.

Now the perPage setting is respected.

Screenshots, screen recording, code snippet

Environment info

WordPress: 6.8.1 Theme: twenty-twentyfive Browser: Chrome

Please confirm that you have searched existing issues in the repo.

  • [x] Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • [x] Yes

Please confirm which theme type you used for testing.

  • [x] Block
  • [x] Classic
  • [x] Hybrid (e.g. classic with theme.json)
  • [ ] Not sure

JelleTempelman avatar Jul 14 '25 08:07 JelleTempelman

While testing this further, I noticed that the perPage setting defined in the pattern is only respected if I switch the Query Loop block to use a custom query type and then change the design. Otherwise, when the block uses the default query (which is also the initial state when selecting a pattern), it continues to fallback to 10 no matter how many times I change the pattern.

So assume this issue is tied to the query type. When the block is using the default query type, the perPage from the pattern isn't applied. And when switching to custom query type, it correctly respects the pattern's perPage

BugReportOnWeb avatar Jul 14 '25 09:07 BugReportOnWeb

This looks similar to #67288. cc @yogeshbhutkar

Mamaduka avatar Jul 14 '25 10:07 Mamaduka

I'm pretty sure this is the same issue as #67288. Let's continue the discussion there.

Mamaduka avatar Jul 15 '25 05:07 Mamaduka