Skip to content
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

Removal of "inherit query from template" breaks query loops in the site editor. #66790

Closed
3 of 6 tasks
rmorse opened this issue Nov 6, 2024 · 8 comments
Closed
3 of 6 tasks
Labels
[Status] Needs More Info Follow-up required in order to be actionable. [Type] Bug An existing feature does not function as intended

Comments

@rmorse
Copy link
Contributor

rmorse commented Nov 6, 2024

Description

It seems that the option "inherit query from template" is missing in 6.7.

From what I can see, the inherit attribute is still there though, and it looks like the logic is that its set to true in the site editor and false in the block editor automatically.

The problem is, we can use query loops in the site editor, that are not intended for archive display.

If I want to show a list of posts in header or footer template for example, this is now forced to be true, meaning it will be forced to connect to the global $wp_query.

I'm not sure if this breaks existing implementations, I assume it would as the attributes would be changed when visiting the site editor and the block attributes are upgraded automatically.

Step-by-step reproduction instructions

  1. Goto the site editor
  2. Edit header template
  3. Add a query loop
  4. Notice there is no possibility to edit the query loop attributes, such as choosing a post type etc.
  5. Visit the frontend, its using the global $wp_query

Screenshots, screen recording, code snippet

chrome_8IZ6zauWHY.mp4

Environment info

Same issue on both 6.7-alpha-59113 and nightly build 6.7-RC3-59353 of WordPress

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
@rmorse rmorse added the [Type] Bug An existing feature does not function as intended label Nov 6, 2024
@ndiego
Copy link
Member

ndiego commented Nov 6, 2024

I just tested in Playground, and it's still working. If you choose "Custom", you create custom queries. The "inherit query from template" messaging was confusing to newer users, so the UI was streamlined a bit. Let me know if that solves this issue for you.

Image

@ndiego ndiego added the [Status] Needs More Info Follow-up required in order to be actionable. label Nov 6, 2024
@rmorse
Copy link
Contributor Author

rmorse commented Nov 6, 2024

Haha wow, I totally didn't realise that the setting had simply changed... must have been rushing... awesome 😅

And yeah renaming it like that is much better!

Thanks

@rmorse rmorse closed this as completed Nov 6, 2024
@ndiego
Copy link
Member

ndiego commented Nov 6, 2024

Haha wow, I totally didn't realise that the setting had simply changed... must have been rushing... awesome 😅

No worries, glad everything is working properly!

@rmorse
Copy link
Contributor Author

rmorse commented Nov 6, 2024

@ndiego
Hmmm, I did find something odd, maybe that's what was throwing me off

chrome_Lq3LhUCcGN.mp4

If you edit the header from single post or page template, you don't get that toggle. But if you edit it from an archive, or somewhere else, you do get it.

Can you replicate?

@ndiego
Copy link
Member

ndiego commented Nov 6, 2024

Yeah, I can.

Image

I believe this is because there's no query to inherit in a single post template, so that option was removed to reduce confusion. @richtabor is this accurate?

@mikachan
Copy link
Member

mikachan commented Nov 7, 2024

I believe this is because there's no query to inherit in a single post template, so that option was removed to reduce confusion.

Adding some thoughts here as I've been involved with trying to improve this block recently. This is intentional and it is meant to reduce confusion, but I understand that might not always be the case 😅 It was changed in #65067. The main reason was that with inherit set to true in a single post, the query will return nothing as there is nothing to inherit, and in order to fix it you need to have some understanding of how the queries are inherited. So to reduce confusion we've hidden that option, as it doesn't make sense to offer it on singular content.

@rmorse
Copy link
Contributor Author

rmorse commented Nov 7, 2024

Thanks for the follow up - and for your work on on this :)

I 100% agree, I always thought this is too technical for most users, and it was problematic when adding the block to a post and "inherit" was set to true by default...

I did confuse myself as you can see though in my hurry and not realising this had also been renamed.

I wonder if my follow up video should be made into a seperate issue - because when we're in an archive template, and edit the header, it shows the toggle, and we can set it to "default", but then when editing the header from another location the toggle dissapears and changes the value to "custom" (possibly without user interaction).

I'm guessing it should always be hidden (or shown) when inside a header/footer as these would be used across multiple types of URLs (single/archive etc)?

@mikachan
Copy link
Member

mikachan commented Nov 7, 2024

I wonder if my follow up video should be made into a seperate issue - because when we're in an archive template, and edit the header, it shows the toggle, and we can set it to "default", but then when editing the header from another location the toggle dissapears and changes the value to "custom" (possibly without user interaction).

Yes good shout, I think this should be a separate issue. Great find too, that's something I never thought to test. Thank you!

I'm guessing it should always be hidden (or shown) when inside a header/footer as these would be used across multiple types of URLs (single/archive etc)?

My initial thoughts are that the option should always be hidden inside a header/footer, as there isn't anything to inherit in these cases, and these template parts should be handled independently to the type of template they're added to (e.g. archive).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] Needs More Info Follow-up required in order to be actionable. [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

3 participants