#11056 closed enhancement (fixed)
More Flexibility in args['post_parent']
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.6 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Query | Keywords: | has-patch commit 3.6-early needs-docs |
Focuses: | Cc: |
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)
#2
@
15 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.
#3
@
12 years 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' ) ) );"
#4
@
12 years ago
See #13927, attachment:13927.diff:ticket:13927. This one looks a bit more complete, and is certainly updated for trunk, at least.
#6
@
12 years ago
yeah, I grep'd for post__in
and went from there - your spirit lives on in the middle there
#7
@
12 years ago
- Owner changed from ryan to markjaquith
- Status changed from new to assigned
Looks good to me. Mark?
#13
@
12 years ago
post-parent-in-tests.diff look good at a glance, but these tests also pass without the post_parent__in
patch applied.
#17
@
12 years ago
- Cc kovshenin added
- Keywords needs-unit-tests removed
Refreshed in 11056.diff and added tests in 11056.tests.diff run with --group 11056
.
#18
@
12 years ago
In 1217/tests:
p.s. I might play around with the posts_where_paged filter and see what that gets me.