WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following custom query written for a page- $menu_loop = new WP_Query( array( 'post_type' => 'page', 'posts_per_page' => 50, 'post_parent' => 616, 'order_by' => 'post_title', 'order' => 'ASC' ) ); while ($menu_loop->have_posts()) : $menu_loop->the_post();

The problem is, when the content is output to the page, it is NOT in alphabetical order by post_title. This has really been mystifying me because if I manually query the DB with- SELECT * FROM wp_2_posts WHERE post_type = 'page' AND post_parent = 616 ORDER BY post_title ASC

then the results are returned correctly. Further, I print_r($menu_loop) and one of the array entries is the actual query sent to the DB and it is wrong and showing- [request] => SELECT SQL_CALC_FOUND_ROWS wp_2_posts.* FROM wp_2_posts WHERE 1=1 AND wp_2_posts.post_parent = 616 AND wp_2_posts.post_type = 'page' AND (wp_2_posts.post_status = 'publish') ORDER BY wp_2_posts.post_date ASC LIMIT 0, 50

which if you look you'll see the ORDER BY statement is sorting by the post date, not the post title.

What am I doing wrong here?

share|improve this question
up vote 0 down vote accepted

Your sorting parameter should be: 'orderby' => 'title'

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.