Opened 13 months ago
Closed 12 months ago
#59225 closed defect (bug) (fixed)
Block themes do not trigger "the loop" correctly
Reported by: | flixos90 | Owned by: | flixos90 |
---|---|---|---|
Milestone: | 6.4 | Priority: | high |
Severity: | normal | Version: | |
Component: | Editor | Keywords: | gutenberg-merge has-patch has-unit-tests has-testing-info |
Focuses: | Cc: |
Description
Currently, block themes do not handle "the loop" correctly. Since their existence, WordPress themes have been expected to have the main WP_Query
object go through the loop of posts when rendering posts. This ensures the WordPress query loop is correctly handled, e.g. calling in_the_loop()
will return true
as expected.
In block themes, this doesn't happen correctly though, the loop is not started when rendering posts which breaks the long-standing expectation that is relied on in both WP core and the plugin ecosystem. This is because the core/post-template
block, when configured to use the global query (via the inherit
attribute), _clones_ the global query object rather than using it directly. This leads to the main query loop never being started since it is only started on the cloned instance.
The only reason this isn't entirely broken is a workaround in the core/post-content
and core/post-featured-image
blocks which forces the loop to start if it hasn't started yet. However, that itself is not a proper fix as it does not cover all core/post-*
blocks (e.g. when rendering posts with only a title and date it wouldn't work), and more importantly introduces bugs on its own, such as #58027.
Change History (14)
This ticket was mentioned in PR #5103 on WordPress/wordpress-develop by @flixos90.
13 months ago
#4
- Keywords has-patch has-unit-tests added; needs-patch removed
This is a mirror of https://github.com/WordPress/gutenberg/pull/49904, as this change technically needs to be made in Gutenberg first and then ported over to WP core. This PR is for reference purposes and also includes the relevant test coverage in a way that is adapted to be included in WP core.
Trac ticket: https://core.trac.wordpress.org/ticket/59225
#5
@
13 months ago
- Keywords has-testing-info needs-testing added
See https://github.com/WordPress/gutenberg/pull/49904 for detailed testing instructions.
@flixos90 commented on PR #5103:
13 months ago
#6
Note: The test failures here are related to https://core.trac.wordpress.org/ticket/58154 / #5104 and should be fixed once that PR has been committed to WordPress core. As such, that PR should be committed first, _before_ porting the Gutenberg changes from https://github.com/WordPress/gutenberg/pull/49904 into core.
This ticket was mentioned in Slack in #core-editor by flixos90. View the logs.
13 months ago
This ticket was mentioned in Slack in #core by joemcgill. View the logs.
13 months ago
#11
@
12 months ago
@hellofromTonya For your visibility, I'm flagging this ticket here as one that would be great to get backported/synced to core sooner than later. I'm aware of the situation in https://wordpress.slack.com/archives/C055Y7FKS7N/p1694112328255489 which appears to be blocking at the moment, but once that is resolved it would be great to do a sync of the Gutenberg packages with some time left before Beta 1.
This ticket was mentioned in Slack in #core by marybaum. View the logs.
12 months ago
#13
@
12 months ago
It looks like the related changes from Gutenberg will land today with https://github.com/WordPress/wordpress-develop/pull/5262 from #59411. It seems that there isn't more work necessary other than testing the integration afterward.
This ticket is fixed by Gutenberg PR https://github.com/WordPress/gutenberg/pull/49904, once that is merged and backported to WP core.
cc @hellofromTonya