[wp-trac] [WordPress Trac] #28012: orderby post__in interferes with menu_order
WordPress Trac
noreply at wordpress.org
Tue May 13 16:01:06 UTC 2014
#28012: orderby post__in interferes with menu_order
------------------------------------------+------------------
Reporter: Matthias82 | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 4.0
Component: Query | Version: 3.9
Severity: normal | Resolution:
Keywords: needs-patch needs-unit-tests | Focuses:
------------------------------------------+------------------
Comment (by DeBAAT):
Might this have to do with the fact that variable $post!__in is only set
in the specific case where $q!['p'] is not set and $q!['post__in'] is?
See the following code, starting at line 2441 of query.php:
{{{
// If a post number is specified, load that post
if ( $q['p'] ) {
$where .= " AND {$wpdb->posts}.ID = " . $q['p'];
} elseif ( $q['post__in'] ) {
$post__in = implode(',', array_map( 'absint', $q['post__in'] ));
$where .= " AND {$wpdb->posts}.ID IN ($post__in)";
} elseif ( $q['post__not_in'] ) {
$post__not_in = implode(',', array_map( 'absint',
$q['post__not_in'] ));
$where .= " AND {$wpdb->posts}.ID NOT IN ($post__not_in)";
}
}}}
Because if this variable is not set, it will not be used in the code,
starting on line 2614:
{{{
// Order by
if ( empty($q['orderby']) ) {
$orderby = "$wpdb->posts.post_date " . $q['order'];
} elseif ( 'none' == $q['orderby'] ) {
$orderby = '';
} elseif ( $q['orderby'] == 'post__in' && ! empty( $post__in ) ) {
$orderby = "FIELD( {$wpdb->posts}.ID, $post__in )";
} elseif ( $q['orderby'] == 'post_parent__in' && ! empty( $post_parent__in
) ) {
$orderby = "FIELD( {$wpdb->posts}.post_parent, $post_parent__in
)";
} else {
// Used to filter values
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/28012#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list