[wp-trac] [WordPress Trac] #28012: orderby post__in interferes with menu_order
WordPress Trac
noreply at wordpress.org
Fri Aug 21 03:35:59 UTC 2015
#28012: orderby post__in interferes with menu_order
------------------------------------------+-------------------------
Reporter: Matthias82 | Owner:
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: Query | Version: 3.9
Severity: normal | Resolution: worksforme
Keywords: needs-patch needs-unit-tests | Focuses:
------------------------------------------+-------------------------
Comment (by Ben_W):
I am afraid the menu_order is interfering the "post_in" order. Please see
my testing query below:
{{{
$argsSticky = array(
'posts_per_page' => 16,
'post_type' => array('post','video','ad_panel','instagram'),
//'post__in' => $stickyPostIdArray,
'post__in' => array(22153,23663,23360,23652),
'cat' => $category_id,
'orderby' =>'post__in',
'paged' => $paged
);
$stickyPosts = new WP_Query($argsSticky);
}}}
The query I get is as follow:
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN
wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
WHERE 1=1 AND wp_posts.ID IN (22153,23663,23360,23652) AND (
wp_term_relationships.term_taxonomy_id IN (15)) AND wp_posts.post_type IN
('post', 'video', 'ad_panel', 'instagram') AND (wp_posts.post_status =
'publish' OR wp_posts.post_author = 53 AND wp_posts.post_status =
'private') GROUP BY wp_posts.ID ORDER BY wp_posts.menu_order, FIELD(
wp_posts.ID, 22153,23663,23360,23652 ) LIMIT 0, 16
The post id 23663 has menu_order=1, and post id 23360 has menu_order=5,
the rest post has menu_order=0, therefore these two post will always
positioned as last 2 posts. because of
{{{
ORDER BY wp_posts.menu_order, FIELD( wp_posts.ID, 22153,23663,23360,23652
)
}}}
This happens on wordpress 4.2.4
--
Ticket URL: <https://core.trac.wordpress.org/ticket/28012#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list