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 a custom WP_Query that looks like this:

 $images = new WP_Query( array( 'post_type' => 'menu-item', 'post_parent' => $this_page_id ) );

My problem is that when using the orderby parameter (see here: http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters) to sort by menu_order (which I need to do for the project). The sort order is not working.

I'm 99% certain the reason it's not working is because I'm directing it to query all children of a specific post and the orderby parameter doesn't "dig that deep into the query" if that makes sense to anyone.

Can anyone offer some help? doing this (the expected solution yields nothing):

     $images = new WP_Query( array( 'post_type' => 'menu-item', 'post_parent' => $this_page_id, 'orderby' => 'menu_order' ) );
share|improve this question
try adding 'order' => 'ASC' and see if anything changes... – Joshua Abenazer Nov 29 '11 at 4:34
So funny! I had tried that before but had a separate error which I later found and then forgot to go back and re-add order => ASC. Thanks! – Brian Nov 29 '11 at 4:41
Add it as an answer if you want the reputation, your answer was correct! – Brian Nov 29 '11 at 4:41
up vote 1 down vote accepted

This query should work.

$images = new WP_Query( array( 'post_type' => 'menu-item', 'post_parent' => $this_page_id, 'orderby' => 'menu_order', 'order' => 'ASC' ) );
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.