Opened 9 years ago
Closed 9 years ago
#36344 closed enhancement (wontfix)
WP_Query: Allow passing a string for post_parent__not_in
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.4.2 |
Component: | Query | Keywords: | |
Focuses: | Cc: |
Description
Improvement for: post-parent-not-in in line 2772. could not use post--not-in as a parameter in a string.
File: wp-includes/query.php
Line: 2772
Type: Enhancement
Example:
if the following query is run it does not work without the improvement
query_posts( 'post__not_in=2&post_status=publish&posts_per_page=15&paged=1' );
URL GitHub: https://github.com/WordPress/WordPress/pull/192
Remove:
$post_parent__not_in = implode( ',', array_map( 'absint', $q['post_parent__not_in'] ) );
Add:
$post_parent__not_in = implode( ',', array_map( 'absint', is_string( $q['post_parent__not_in'] ) ? explode( ',', $q['post_parent__not_in'] ) : $q['post_parent__not_in'] ) );
Greetings from Mexico.
Best regards
Gustavo Martínez
Attachments (2)
Change History (5)
#1
@
9 years ago
- Summary changed from Improvement for: post_parent__not_in in line 2772. could not use post__not_in as a parameter in a string. to WP_Query: Allow passing a string for post_parent__not_in
#2
@
9 years ago
post_parent__not_in
is not the only parameter that is required to be an array. In fact, only few can be either a string or an array, e.g post_type
, orderby
and post_status
. For these params it makes sense, because most of the time you'll only need to pass a single string.
In my opinion array-only makes sense for post_parent__not_in
because developers usually populate it with dynamic values (e.g. from an other query).
In any case, if this enhancement gets traction, post_parent__not_in
shouldn't be the only one being changed.
GitHub