#59415 closed defect (bug) (worksforme)
Post Content Block displays another Post's content when in a Query Loop filtered by Category
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 6.4 |
Component: | Query | Keywords: | reporter-feedback close |
Focuses: | Cc: |
Description
The out-of-the box Post Content block is not working correctly when you insert it into the Post Template block of the Query Loop in the Blog Home Template.
Steps to Reproduce:
- Start with a fresh install of WordPress WordPress 6.4-alpha-56628 running Twenty Twenty-There theme, no plugins active.
- Publish a new post: title: “Title A”, content: “Content A”, excerpt text: "Excerpt A", set to new Category “Category A”
- Publish a new post: title: “Title B”, content: “Content B”, excerpt text: "Excerpt B", set to new Category “Category B”
- Edit the Blog Home template:
- Edit the Query Loop: unset “Inherit query from template”
- Filter on Taxonomies, “Category A”
- Edit the Post Template block: insert a Post Content block
Test: Using another instance of a browser where the user is not signed-in, the home page will show “Title A” (correct), excerpt “Excerpt A” (correct), and “Content B” (incorrect).
If you choose to filter on Category B, it works fine. But change the published time of Post B to prior to Post A and the results are again wrong.
When you add multiple posts, only the first one is incorrectly displayed. If Category A is correct, Category B will display incorrectly, and vice versa.
Note also that the data always displays correctly in the browser when editing on the Admin screen.
I have isolated the area that corrects the issue, but this is NOT the solution… /wp-includes/blocks/post-content.php lines 44-47.
// When inside the main loop, we want to use queried object // so that `the_preview` for the current post can apply. // We force this behavior by omitting the third argument (post ID) from the `get_the_content`. $content = get_the_content();
Change to
$content = get_the_content(null,false,$post_id);
There is something deeper in the logic here and hopefully a WP Developer familiar with the routine can address it. I have seen this in WP 6.3.1 and used the current dev version to verify the issue still exists.
Attachments (2)
Change History (5)
#1
@
16 months ago
- Keywords reporter-feedback close added
Hello @john809,
Welcome to WordPress Core's Trac :) Thank you reporting the issue.
The wp-includes/blocks/post-content/php
(and the other files in that same directory) are maintained within the Gutenberg repository.
The discussion, investigation, and possible fix needs to happen in the Gutenberg repository.
Can you please report this issue upstream in Gutenberg? https://github.com/WordPress/gutenberg/issues
Once reported, can you please comment with a link to the issue, i.e. comment to this Trac ticket? Then this Trac ticket can be closed as reported-upstream
.
Thank you :)
Blog Home Template with added Post Content block and Filter by Category A