#13927 closed enhancement (duplicate)
post_parent query var should accept an array
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Query | Version: | |
| Severity: | normal | Keywords: | has-patch |
| 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)
Hm... didn't think about 'post_parent__not_in'.
comment:4
johnjamesjacoby — 2 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?
Have a ticket number over on bbPress Trac? I'll contribute some code I wrote that will implement this via a plugin.
Yeah, keep in mind that you can easily implement custom query vars using filters: 'posts_where', 'posts_clauses' etc.
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;
- Resolution set to duplicate
- Status changed from new to closed
Duplicate of #11056.
comment:10
nacin — 8 months ago
- Milestone Future Release deleted

Just use 'post_parent'