Make WordPress Core

Opened 17 months ago

Closed 16 months ago

Last modified 16 months ago

#59415 closed defect (bug) (worksforme)

Post Content Block displays another Post's content when in a Query Loop filtered by Category

Reported by: john809's profile john809 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:

  1. Start with a fresh install of WordPress WordPress 6.4-alpha-56628 running Twenty Twenty-There theme, no plugins active.
  1. Publish a new post: title: “Title A”, content: “Content A”, excerpt text: "Excerpt A", set to new Category “Category A”
  1. Publish a new post: title: “Title B”, content: “Content B”, excerpt text: "Excerpt B", set to new Category “Category B”
  1. 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)

BlogHomeTemplate.pdf (119.3 KB) - added by john809 17 months ago.
Blog Home Template with added Post Content block and Filter by Category A
Output.pdf (34.7 KB) - added by john809 17 months ago.
Output showing Content B when Content A was expected.

Download all attachments as: .zip

Change History (5)

@john809
17 months ago

Blog Home Template with added Post Content block and Filter by Category A

@john809
17 months ago

Output showing Content B when Content A was expected.

#1 @hellofromTonya
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 :)

#2 @john809
16 months ago

  • Resolution set to worksforme
  • Status changed from new to closed

Retested with wordpress-6-4-beta-3 before reporting upstream.

Retesting shows this issue has been corrected!

Closing this issue.

#3 @hellofromTonya
16 months ago

  • Milestone Awaiting Review deleted

WooHoo thanks @john809 for retesting :)

Note: See TracTickets for help on using tickets.