[wp-trac] [WordPress Trac] #21618: WP_Query should accept menu_order as a query arg
WordPress Trac
wp-trac at lists.automattic.com
Fri Aug 17 16:30:03 UTC 2012
#21618: WP_Query should accept menu_order as a query arg
----------------------------+-----------------------------
Reporter: wonderboymusic | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 2.0
Severity: normal | Keywords: has-patch
----------------------------+-----------------------------
With custom post types, you can use the Posts table for basically
anything. {{{menu_order}}} can be especially useful for holding foreign
ids (after you add an index to it). The problem is that {{{menu_order}}}
can't be passed to {{{WP_Query}}}:
{{{
add_filter( 'query', function ( $sql ) { error_log( $sql ); return $sql; }
);
$stuff = new WP_Query( array( 'menu_order' => 5 ) );
exit();
// SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND
wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') ORDER
BY wp_posts.post_date DESC LIMIT 0, 10
}}}
My patch fixes that, the result is now:
{{{
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND
wp_posts.menu_order = 5 AND wp_posts.post_type = 'post' AND
(wp_posts.post_status = 'publish') ORDER BY wp_posts.post_date DESC LIMIT
0, 10
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/21618>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list