[wp-trac] [WordPress Trac] #59415: Post Content Block displays another Post's content when in a Query Loop filtered by Category
WordPress Trac
noreply at wordpress.org
Wed Sep 20 20:34:26 UTC 2023
#59415: Post Content Block displays another Post's content when in a Query Loop
filtered by Category
--------------------------+-----------------------------
Reporter: john809 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: trunk
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
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:
1. Start with a fresh install of WordPress WordPress 6.4-alpha-56628
running Twenty Twenty-There theme, no plugins active.
2. Publish a new post: title: “Title A”, content: “Content A”, excerpt
text: "Excerpt A", set to new Category “Category A”
3. Publish a new post: title: “Title B”, content: “Content B”, excerpt
text: "Excerpt B", set to new Category “Category B”
4. 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.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59415>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list