I'm pulling my hair out here... It's just not working.
I have a custom post type called "our_work" and I want to list all the posts from that post type to put into a menu... So the query I'm doing is this:
$pages = get_posts(array( 'post_type' => 'our_work', 'post_status' => 'publish', 'orderby' => 'post_title', 'numberposts' => -1 ));
That's sweet... It displays all the posts just fine. But I can't for the life of me get the orderby working properly.
I've checked the query it's making and like so:
<?php echo $GLOBALS['wp_query']->request; ?>
and it is spitting out this:
SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'our_work' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') ORDER BY wp_posts.menu_order, wp_posts.post_date DESC LIMIT 0, 10
Which would suggest everything is sweet... But the ORDER BY value isn't being set. Driving me nuts. I've tried all sorts of different variations of order by and post_title but can't get anywhere so any help would be appreciated.