[wp-trac] [WordPress Trac] #8071: Refrain from querying all the comments on a post when paged
WordPress Trac
noreply at wordpress.org
Fri Sep 25 15:12:11 UTC 2015
#8071: Refrain from querying all the comments on a post when paged
------------------------------------+---------------------------
Reporter: markjaquith | Owner: boonebgorges
Type: enhancement | Status: assigned
Priority: normal | Milestone: 4.4
Component: Comments | Version: 2.7
Severity: normal | Resolution:
Keywords: has-patch dev-feedback | Focuses:
------------------------------------+---------------------------
Comment (by boonebgorges):
In [changeset:"34546"]:
{{{
#!CommitTicketReference repository="" revision="34546"
Introduce hierarchical query support to `WP_Comment_Query`.
Comments can be threaded. Now your query can be threaded too! Bonus: it's
not totally insane.
* The new `$hierarchical` parameter for `WP_Comment_Query` accepts three
values:
* `false` - Default value, and equivalent to current behavior. No
descendants are fetched for matched comments.
* `'flat'` - `WP_Comment_Query` will fetch the descendant tree for each
comment matched by the query paramaters, and append them to the flat array
of comments returned. Use this when you have a separate routine for
constructing the tree - for example, when passing a list of comments to a
`Walker` object.
* `'threaded'` - `WP_Comment_Query` will fetch the descendant tree for
each comment, and return it in a tree structure located in the `children`
property of the `WP_Comment` objects.
* `WP_Comment` now has a few utility methods for fetching the descendant
tree (`get_children()`), fetching a single direct descendant comment
(`get_child()`), and adding anothing `WP_Comment` object as a direct
descendant (`add_child()`). Note that `add_child()` only modifies the
comment object - it does not touch the database.
Props boonebgorges, wonderboymusic.
See #8071.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/8071#comment:30>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list