[wp-trac] [WordPress Trac] #62953: Add post_ancestor as query var to WP_Query class
WordPress Trac
noreply at wordpress.org
Thu Feb 20 23:10:09 UTC 2025
#62953: Add post_ancestor as query var to WP_Query class
-------------------------------------------------+-------------------------
Reporter: bbpaule | Owner: bbpaule
Type: enhancement | Status: assigned
Priority: normal | Milestone: Awaiting
| Review
Component: Query | Version: trunk
Severity: normal | Resolution:
Keywords: has-patch has-screenshots has- | Focuses: rest-api
testing-info has-unit-tests |
-------------------------------------------------+-------------------------
Comment (by peterwilsoncc):
I've added a [https://github.com/WordPress/wordpress-
develop/pull/8338#pullrequestreview-2631374412 very long comment on the
associated pull request].
The most important thing is that in order for this to work as expected,
recursive database queries would need to be made to determine the complete
(unbounded) post tree under the requested ancestor post, which would then
be followed by a `post__in` query to get the descendants and ensure the
number of found rows and post count is correct.
This recursion would result in a significant performance impact on sites,
especially those with deep trees of posts, such as some of the handbooks
on WordPress.org.
I've included A way of doing it in my comment, I'm sure there are other
approaches that would work but they'd all involve unbound queries of one
form or another.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62953#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list