-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query Loop: Default settings don't render any items when inserted in content #64746
Comments
Suggestion: instead of "Default" what do you think about the label "Inherit"? It is much more specific, the word default isn't very helpful. If someone doesn't know what "Inherit" means, at least it is a hook to go googling for. "Inherit query loop" is better than "Default query loop" IMO. |
Template-wise, the Query Loop should almost always be "Default", to allow the template to orient the block. Ideally, the default state of the Query Loop would render the index template's query loop (using posts per page, "post" post type, etc). That way it "just works" and you don't have to switch to "Custom" unless it's an explicit decision to do so. |
An alternative is to have the "Query Type" control available when editing via a template. Not 100% sure about it, but what do you think? cc @WordPress/gutenberg-design |
I quite like the word "Default" over "Inherit". Default suggests that this is what you should have selected if you're not sure what you're doing. It's also what you should be using most of the time. That supports this:
It should just work. Custom disconnects this from reading settings in WordPress, which will accumulate confusion over time: why isn't my template respecting my updated reading settings?
Not sure what you mean, do you mean hiding this control in templates and showing when editing a query on, e.g. a page? From my read here, the issue is that in the page/post editor, an inserted Query loop set to default shows posts, but when you preview/publish said page/post, nothing appears. This feels like a bug, and if the frontend shows no posts for a particular query, then neither should the editor. That seems the first issue to fix, bringing these two in sync. That's assuming it's intended that the query loop should not show posts in this context. Either that's enough to get users to understand that they need to provide a custom query for anything to show up. If it isn't, we could potentially show a notice, just like we show yellow contrast notices, that "This query did not return any results." |
This is pretty much what I've been advocating for a long time. My understanding aligns with @alaczek... technically the frontend is correct here; a Query placed inside a page and set to inherit will retrieve data from the page itself. This has no practical use (that I can think of), so it seems reasonable to me that a Query inside a Content block would always be custom. |
I'm not personally a fan of changing a block default based on where you insert that block, but happy to defer to other consensus here. Mostly though, if the frontend for the default query shows something different than the editor, we should fix the editor bug. This would be necessary even if we did flip the defaults, so when you toggled default, it'd show the actual end result, 1:1 with the frontend. Useless sure, but current behavior feels like a misleading error. |
We should double-check whether the frontend behavior is correct. If it is then the idea isn't to change the default; it's to hide the 'Query type' control altogether, because it's not serving any practical purpose. |
I've started taking a look at how to address this, and currently have a draft PR here: #65067. I'm not sure if I'm going in the right direction, but I wanted to share early in case it looks promising. I think the current front end behavior is correct, but I'm still not sure if this is intuitive enough for the end user. In any case, this draft PR at least aligns the Editor and front end query results. |
The Query Loop block can exist in two different modes:
This works great in the context of editing a Template. But when you insert a Query block inside content and leave the settings on "Default" it shows you a list of posts in the editor. But on the frontend it never displays anything because there is no global query to inherit from.
Proposed Solution
When there is no global query to inherit from the "Default" settings should display X (global posts per page setting) posts of the default posts post type.
The text was updated successfully, but these errors were encountered: