#11056 closed enhancement (fixed)
More Flexibility in args['post_parent']
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.6 |
| Component: | Query | Version: | |
| Severity: | normal | Keywords: | has-patch commit 3.6-early needs-docs |
| Cc: | djpaul@…, japh@…, kovshenin |
Description
I am struggling to reduce query count on some of my custom code, and frankly I can't see a way to do it in the existing code base.
One of the stumbling blocks is get_children() relying on the WP_Query::get_posts() restriction for is_numeric($qpost_parent?)
The cost is 3 queries for every call to get_children().
Either I am incredibly dense about how attachment queries are supposed to work, or there needs to be a way to query multiple parents in one call.
Attachments (4)
Change History (24)
comment:1
miqrogroove — 4 years ago
comment:2
miqrogroove — 3 years ago
- Milestone changed from 3.0 to Future Release
The filter I wrote still works so far. It's ugly but I don't have the time to hack WP_Query before beta starts.
wonderboymusic — 8 months ago
comment:3
wonderboymusic — 8 months ago
- Keywords has-patch added
- Milestone changed from Future Release to 3.5
Introduce post_parent__in, post_parent__not_in - patch attached.
Example usage:
php -r "require 'wp-load.php'; \ print_r( get_posts( array( 'post_parent__in' => array( 47 ), 'post_type' => 'page', 'orderby' => 'post_parent__in' ) ) );"
See #13927, attachment:13927.diff:ticket:13927. This one looks a bit more complete, and is certainly updated for trunk, at least.
comment:6
wonderboymusic — 8 months ago
yeah, I grep'd for post__in and went from there - your spirit lives on in the middle there
- Owner changed from ryan to markjaquith
- Status changed from new to assigned
Looks good to me. Mark?
comment:10
ryan — 8 months ago
- Keywords needs-unit-tests added
comment:11
nacin — 8 months ago
- Priority changed from high to normal
Agreed with Ryan, could use some tests.
wonderboymusic — 8 months ago
comment:12
wonderboymusic — 8 months ago
attached some Unit Tests
comment:13
nacin — 8 months ago
post-parent-in-tests.diff look good at a glance, but these tests also pass without the post_parent__in patch applied.
comment:14
nacin — 7 months ago
- Keywords 3.6-early added
- Milestone changed from 3.5 to Future Release
comment:16
wonderboymusic — 5 months ago
- Milestone changed from Future Release to 3.6
comment:17
kovshenin — 3 months ago
- Cc kovshenin added
- Keywords needs-unit-tests removed
Refreshed in 11056.diff and added tests in 11056.tests.diff run with --group 11056.
comment:18
nacin — 3 months ago
In 1217/tests:
comment:19
nacin — 3 months ago
- Resolution set to fixed
- Status changed from assigned to closed
In 23436:
comment:20
alexvorn2 — 3 months ago
- Keywords needs-docs added

p.s. I might play around with the posts_where_paged filter and see what that gets me.