[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
Fri Dec 19 11:32:29 UTC 2014
#30778: Extend WP_Query to allow for querys of posts with attachments with certain
metadata
----------------------------+-----------------------------
Reporter: pampfelimetten | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 4.1
Severity: normal | Keywords:
Focuses: |
----------------------------+-----------------------------
Currently, if you want to find posts with attachments with certain meta
data, you have to use two different queries. One for all the attachments
with the right metadata, then collect the parent Ids, and a second query
where you set the 'post__in' argument.
This works, but it is clumsy to solve this in php. It would be great if
you could set off something like:
{{{
$args['post_type'] = 'post';
$args['post_status'] = 'publish';
$args['s'] = 'searchtext';
$args['child_query']['post_type'] = 'attachment';
$args['child_query']['post_status'] = 'inherit';
$args['child_query']['posts_per_page'] = '-1';
$args['child_query']['post_mime_type'] = 'audio';
}}}
This way, you could easily query for posts with certain attachment meta
data, for example for a post with mp3s with a bitrate higher than 128kb.
Take a look at our site if you want to see a real life use case:
http://cba.fro.at/search
Our users can set off quite complex querys with multiple metadata
specification, some of which is saved as metadata of posts, some of which
is saved as metadata of attachments of these posts. But us I said, we have
to split it into two queries at the moment.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/30778>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list