[wp-trac] [WordPress Trac] #30778: Extend WP_Query to allow for querys of posts with attachments with certain metadata
WordPress Trac
noreply at wordpress.org
Mon Jan 12 20:42:24 UTC 2015
#30778: Extend WP_Query to allow for querys of posts with attachments with certain
metadata
----------------------------+----------------------
Reporter: pampfelimetten | Owner:
Type: enhancement | Status: closed
Priority: normal | Milestone:
Component: Query | Version: 4.1
Severity: normal | Resolution: wontfix
Keywords: | Focuses:
----------------------------+----------------------
Changes (by boonebgorges):
* status: new => closed
* resolution: => wontfix
* milestone: Awaiting Review =>
Comment:
An interesting idea, but I'm not sure I see the value. If the idea is that
the child_query will accept all params of `WP_Query`, then I suppose the
internals would work like this: a secondary `WP_Query` object would be
fired up, and either the SQL would be retrieved and put into a
`$wpdb->posts.ID IN` subquery on the main query, or the matching IDs would
be fetched and parsed into `post__in`. Either way, you're saving little to
no computational overhead. And if you're forced to assemble what amounts
to a new array of query vars for 'child_query', then you're not really
saving much time in PHP either. This would do the same thing:
{{{
$attachment_query = new WP_Query( array(
'post_type' => 'attachment',
'post_status' => 'inherit',
'posts_per_page' => '-1',
'post_mime_type' => 'audio',
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
) );
$post_ids = wp_list_pluck( $attachment_query->posts );
$main_query = new WP_Query( array(
'post_type' => 'post',
'post_status' => 'publish',
's' => 'searchtext',
'post__in' => $post_ids,
) );
}}}
IMO, this is just as readable as the proposed 'child_query', and produces
no overhead beyond what would presumably be required for 'child_query'.
Closing as wontfix, though if I've misunderstood, or if you have more
details on how the proposed feature would be a significant improvement on
the above, please feel free to reopen with those details.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/30778#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list