Skip to content

Query Loop: please don't treat template parts & synced patterns as singular #70622

@Andrew-Starr

Description

@Andrew-Starr

Description

Query loop is automatically changing the inherit property from true to false, when in a singular object (post, page custom etc) but this also means that template parts and synced patterns are regarded as singular.

I can understand the reasoning behind this as a query loop placed in a page cannot inherit the query, but this is causing issues when for example an archive template contains either a synced pattern or template part that in turn contains the query loop. In this case the inherit attribute is auto changed to false, and is breaking the display of the query loop.

Step-by-step reproduction instructions

Place a query loop with inherit set to true, inside either a template part or a synced pattern.
Place the template part or synced pattern inside the archive template.
Check the front end and see that the query is inherited perfectly OK (only posts from correct category or tag are displayed).

This next part is where the weirdness happens:
Edit the template part or synced pattern, e.g. just make a small change to the post title color or font size, and save the part/pattern.
View the frontend and notice that the query now doesn't inherit the correct query.

What is happening is that the query loop inherit:true is auto changed to inherit:false but it doesn't trigger a "save changes " prompt, so everything appears to work correctly, until you make an edit, and then the auto changed inherit:false is saved along with the other changes.

Screenshots, screen recording, code snippet

No response

Environment info

No response

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

  • Yes

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

  • Yes

Please confirm which theme type you used for testing.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Block] Query LoopAffects the Query Loop Block[Status] In discussionUsed to indicate that an issue is in the process of being discussed[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions