[wp-trac] [WordPress Trac] #56992: The Loop displays incorrect data for queries started with `fields => 'id=>parent'`.

WordPress Trac noreply at wordpress.org
Mon Mar 3 21:44:01 UTC 2025


#56992: The Loop displays incorrect data for queries started with `fields =>
'id=>parent'`.
-------------------------------------------------+-------------------------
 Reporter:  peterwilsoncc                        |       Owner:
                                                 |  peterwilsoncc
     Type:  defect (bug)                         |      Status:  closed
 Priority:  normal                               |   Milestone:  6.8
Component:  Query                                |     Version:  3.1
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests dev-        |     Focuses:
  feedback 2nd-opinion                           |
-------------------------------------------------+-------------------------
Changes (by peterwilsoncc):

 * owner:  (none) => peterwilsoncc
 * status:  new => closed
 * resolution:   => fixed


Comment:

 In [changeset:"59919" 59919]:
 {{{
 #!CommitTicketReference repository="" revision="59919"
 Query: Ensure secondary loops populate the full global post.

 Modifies `WP_Query::the_post()` to ensure the entire global post object is
 populated regardless of the `fields` parameter initially set by the
 developer.

 In secondary loops, this ensures that `get_the_content()` and other getter
 functions operate as documented when called without a post ID and return
 the appropriate data for the global post object.

 This introduces consistency when starting the loop and the `fields`
 parameter is set to `id=>parent` to the behaviour when set to either `all`
 or `ids`.

 There is no change to the `WP_Query::$posts` parameter nor when a query is
 made without starting the secondary loop, ie without calling
 `WP_Query::the_post()`.

 Props juzar, mukesh27, oglekler, peterwilsoncc, sirlouen, joemcgill.
 Fixes #56992.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56992#comment:19>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list