#13927 closed enhancement (duplicate)
post_parent query var should accept an array
Reported by: | nacin | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Query | Keywords: | has-patch |
Focuses: | Cc: |
Description
if ( is_numeric($q['post_parent']) ) $where .= $wpdb->prepare( " AND $wpdb->posts.post_parent = %d ", $q['post_parent'] );
It'd be nice to be able to either pass an array, or introduce post_parent__in and __not_in vars.
Attachments (3)
Change History (13)
#4
@
14 years ago
Running into this as an issue with the bbPress plugin and the topics and replies widgets. Since forums can be 'private' I specifically need...
post_parent__not_in
...to exclude private forum IDs from the widgets completely. The alternative is quite ugly, involving using meta queries and storing an additional meta entry for every topic/reply with the forum status. Ugly because if the forum status changes, every topic/reply in that forum needs to be updated.
Any way to scoot this into 3.2-early?
#5
@
14 years ago
Have a ticket number over on bbPress Trac? I'll contribute some code I wrote that will implement this via a plugin.
#7
@
14 years ago
Yeah, keep in mind that you can easily implement custom query vars using filters: 'posts_where', 'posts_clauses' etc.
#8
@
14 years ago
Attached file will implement post_parent__in
and not__in
. It'll noop automatically once it's implemented in core, if added to WP::$private_query_vars. Originally this had some other code:
The other code I wrote avoided private_query_vars for the check and did this:
$qv_test = $wp_query->fill_query_vars( array() ); if ( isset( $qv_test['post_parent__in'] ) ) return $where;
Just use 'post_parent'