-
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
Feature request: Query Loop - Disable the "Inherit Query from Template" setting by default when the QL is added to a page #50790
Comments
In addition, only some templates can inherit a query. For example, a query block in a front page template, 404, or custom template (the type you assign to a post or page) does not display anything if the setting is enabled. |
Just discovering this issue as I was about to open a similar one: Based on the findings in #49904 and WordPress/wordpress-develop#5104, I agree the default and UI for the "Inherit Query from Template" setting ( Here's what I propose:
So really, it makes no sense to inherit the main query within a specific post. Why would you want to have the same query as is already visible on the page within a post on that page, especially given that it would change depending on where you are? Where the query loop block does make sense within a specific post is for example to display an entirely separate query, e.g. other posts in a specific category or something like that. But such use-cases would not rely on inheriting the main query. Therefore I think at a minimum we should change the default for those usages to |
That is the current default behavior and it makes perfect sense in this context.
I agree that it would be the best approach to change that value upon insertion, and we could use a block variation registered only in that context that would take care of the necessary modification.
I couldn't agree more with all the points @felixarntz raised. We would still need to respect the Query Loop blocks inserted with the I would love to hear from @ntsekouras who helped to shape how Query Loop block works today to ensure we don't miss anything important. |
I have nothing more to add here. I agree with the issue/comments and I actually had a PR for that, which might had some nuances and also didn't get much traction, and I eventually closed it. |
I see in the PR some logic that sets the |
+1 Ran into this issue today. |
Adding this to the polish board in hopes someone might be able to tackle this :) |
Apologies for my tenuous grasp on the concepts but I could be one of the many users that run into this issue. I cannot quite understand why if I create a page with inherit=false for the sub-property of a query loop block, through the rest api, with a working query loop block, it subsequently defaults to only inherit the global context for the template. Here is a sample of working block code that renders fine when pasted from one page to the next in the back end editor, but if a user creates content remotely and this exact same native block code is used, it seems to be edited by another process and the sub-query parameters are wiped out, or appear to be in the editor but not in the database? and the database is not what's used. Is there a method to disable this or use what is actually stored in the content for the query loop sub-properties, by chance? Any background info or if this is the wrong place please advise, otherwise +1 from me Here's the sub-property portion of the gutenberg native unedited block, If a user Pastes this from one page to another, it loads without issue If a user Imports or use REST api or otherwise for the same code block, it subsequently becomes the below in the editor, although I actually think it is the same as above in the database? (this shows no related results in the editor in the example where it's a page and the user is trying to use the query loop to display a list of pages related to the parent, obviously given the params) And on the front end, rendered, it actually shows 1 result, per behavior described above, the page itself. Thanks |
I'm putting together a meetup presentation and ran into this issue. So I went back to the "Taking advantage of query loops" training video where it is recommended to disable "Inherit Query from Template." This is again repeated later in the video. The recommendation is to toggle it off "to customize the query." It's not clear what happens when you toggle it on, other than "certain customization options will be hidden." To see the query look right in the editor and then to not see any results on the front end is not only confusing, it could be a big time waster for someone to figure out. |
Considering @ntsekouras' Context detection for Query block would cover and solve this issue as well, are we ok closing this issue in its favor? |
Closing then in favor of #30369; we can reopen if necessary. |
What problem does this address?
When a Query Loop is used in a template, it is often used to display posts of a certain taxonomy, and it inherits the taxonomy query from the template that created it.
A Query Loop might also be added to a page in order to make a blog page, displaying recent posts. In this case, the "Inherit Query from Template" setting will cause the QL to display no posts at all because the Page template does not contain any taxonomies to inherit. This could be confusing for a user who doesn't understand the "Inherit Query from Template" setting because the QL Block will display posts correctly in the page editor, but the QL will appear blank on the website.
What is your proposed solution?
Disable the "Inherit Query from Template" setting by default when the QL is added to a page and/or remove the setting in this context.
The text was updated successfully, but these errors were encountered: