Skip to content

Context detection for Query block #30369

@ntsekouras

Description

@ntsekouras

We need to find a way to detect the context a Query block 'lives' and handle any settings needed appropriately. By context I mean FSE context (site-editor) or a page/post (post-editor). Moreover is valuable to even know the kind of template we are on FSE context (related: #29438).

Noting that we'll also have to take into account what happens when we are in post-editor and we edit the template from there.

There is an inherit property in Query which defaults to true and with that set, the Query's query for fetching results is inherited from the global query. In a single page there is no much use in having an inherit Query (doesn't fetch anything), but instead a custom one. On the other hand in an archive or index template proper results are shown without taking into account any other previously explicitly set options (like the number of posts).

Some prior art is here: #27972, where templateSlug is passed as context and is used for now in QueryLoop to set the proper postType if we are in an archive template.

Metadata

Metadata

Assignees

Labels

[Block] Query LoopAffects the Query Loop Block[Feature] Site EditorRelated to the overarching Site Editor (formerly "full site editing")[Type] EnhancementA suggestion for improvement.
No fields configured for Enhancement.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions