[wp-trac] [WordPress Trac] #55745: FSE post-content block is using wrong "first" item in the query loop

WordPress Trac noreply at wordpress.org
Mon May 16 16:00:43 UTC 2022


#55745: FSE post-content block is using wrong "first" item in the query loop
--------------------------+-----------------------------
 Reporter:  Trekky        |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Themes        |    Version:  5.9.3
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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
 {{{#!php
 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!

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55745>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list