Opened 19 months ago
#55745 new defect (bug)
FSE post-content block is using wrong "first" item in the query loop
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 5.9.3 |
Component: | Themes | Keywords: | |
Focuses: | Cc: |
Description
Hey,
I've created a block based theme for a Full-Site-Editing experience and noticed the following problem:
I would like to show only posts from a specific category on the frontpage and created a template with the following content (simplified):
<!-- wp:template-part {"slug":"header","tagName":"header","className":"site-header"} /--> test <!-- wp:group {"tagName":"main","layout":{"inherit":true}} --> <main class="wp-block-group"> <!-- wp:query {"queryId":0,"query":{"perPage":10,"pages":0,"offset":0,"postType":"post","categoryIds":[7],"tagIds":[],"order":"desc","orderBy":"date","search":"","exclude":[],"sticky":"","inherit":false}} --> <div class="wp-block-query"> <!-- wp:post-template --> <!-- wp:post-title {"isLink":true} /--> <!-- wp:post-content /--> <!-- /wp:post-template --> <!-- /wp:query --> </main> <!-- /wp:group --> <!-- wp:template-part {"slug":"footer","tagName":"footer","className":"site-footer"} /-->
When using the block "post-content" the wrong post content is shown. When using post-excerpt the correct excerpt is used.
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
the_post()
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.
I hope someone gets a solution for the problem.
Thank you very much!