Open Trekky12 opened 2 years ago
I'm not the technical expert here, but worked a lot with Gutenberg and I'm not sure if this is intended behavior and something Gutenberg can handle currently. Yet it is an interesting use-case.
This is a challenge from design & technical viewpoints:
post-content
block, which could contain any and all kinds of blocks inside, depending on what the user puts in there. Rendering this inside a query-loop, in e.g. a grid, would quickly become a design problem.I can see a use-case where you want to show a full text post, (titles, paragaph, lists, etc), like old times if we wanted to show a blog query and show the first post in full. But this is probably a hard use-case to roll out dynamically.
Another idea is to go with functionality to give 'post-excerpt' block the functionality of returning the full body text. But it will still need to parse blocks to know what is the full body text, and how does the editor know what to show and what not?
Hey @Humanify-nl,
thank you for your input. Actually I didn't think of the problem with recursive Query Loop blocks, but yes this could be a problem.
So do you think the use case to show full post contents in a Query Loop shouldn't be supported or do you think it is not easy to solve?
Despite these challenges there is still the problem that the content of another post is shown and the content doesn't match the post.
So do you think the use case to show full post contents in a Query Loop shouldn't be supported or do you think it is not easy to solve?
I think it is not easy to solve, yet I don’t know how the core team is looking at this.
My opinion is that this remains an edge case, which for now needs to be solved with a custom solution. But who knows what the future brings.
Thank you for your opinion. Do you have an idea how a custom solution can be done?
This issue is very similar to #40743.
Since I was able to reproduce the issue in this comment, I will remove Needs Testing
label.
I was also able to reproduce this with a "latest posts" homepage, where I have two Query Loops on index.html
. One inherits the query from the page and shows title + date, the second is a specific category, and shows date + content. In this case, the Post Content block in the second Query Loop is overridden by the first post from the main query.
If I add a Post Content to that first Query Loop, the second one works.
I think it has something to do with how the content is (not) generated in get_the_content
, specifically here, the conditional is true so it uses the globals instead of generating it from the correct post.
Unfortunately I'm not sure what a good fix is — when I tried removing the conditional around the_post
here, I got a different incorrect post content… so I'm just sharing my tracking journey.
I'm going to remove the "post excerpt" label, since excerpts are working correctly as noted in the description and in my testing. Also, adding the "bug" label.
Description
The post-content block in a query loop on a page with the global query loop shows the wrong content.
Apparently the problem lies in the post-content.php file (https://github.com/WordPress/WordPress/blob/aeb3b7530af57db885dfa8f377a7c6aa22e309bd/wp-includes/blocks/post-content.php#L42) where
is called. When this call is removed everything is working as expected. It seems this workaround for "third-party plugins" doesn't handle all edge cases. In this case the latest post on the whole site is saved as the_post() instead of the latest post of the query.
Maybe this is related to the issue #40743
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
No response
Environment info
No response
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