thanks to a member here i display my Parent Pages in a 2 column grid with title and excerpt. But for some reason i can't figure out how to sort all 5 Pages by the menu order for example or the order number i assigned. i display them by using

query_posts( 'post_type=page&post_parent=0' );

so that the child Pages won't displayed. but i can't figure out how to order them.. Any ideas??? thanks in advance! Dan

1 Answer 1



First a advice: don't use query_posts to get your pages. Use get_pages instead. Here is how you can do what you are asking using get_pages.

get_pages( array( 'parent' => 0, 'sort_column' => 'menu_order' ) );

You can also specify whether you want to sort in ascending order or in descending order. Default sorting order is ascending.

get_pages( array( 'parent' => 0, 'sort_column' => 'menu_order', 'sort_order' => 'desc' ) );

For more information check get_pages on codex.

In case if you want to keep using query_posts, here is how you can order pages by menu order, you will need to use orderby argument.

query_posts( 'post_type=page&post_parent=0&orderby=menu_order' );
  • Thanks Hameedullah, unfortuantely it doesn't work this way. i have tried exactly this before after reading through get_pages codex. For some reason this method only calls the same parent page where it is loaded, so that i have the same page twice on a page. all other pages (children and parents) are not being displayed, although i was sure it should work exactly this way, but it doesnt... Any ideas what that could be?
    – Dan
    Commented Dec 29, 2011 at 23:55
  • can you show your template code which is displaying the page? at least the part before get_pages. Because get_pages should return all your parent pages and you can also exclude the page on which you are displaying this list of parent pages. Commented Dec 30, 2011 at 6:15
  • Hi, this is the code how i use it now. if i change the query_post to your mentioned code it will give me only the same page again. hope that helps. thanks a lot! <br/> <div id="container2"> <div id="content2"> <br/> <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts(array( 'post_parent' => 6, 'post_type' => 'page')); get_template_part( 'leistungen', 'grid' ); wp_reset_query(); ?> <br/> </div><!-- #content2 --> </div><!-- #container2 -->
    – Dan
    Commented Dec 30, 2011 at 8:06
  • Dan, I am not sure what is caussing this strange behaviour, but I have updated my answer to include query_posts example to demonstrate how can you order pages based on their menu_order. Commented Dec 30, 2011 at 13:21
  • Dan, it looks like the code you posted in the comments here you're setting the 'post_parent' => 6; is that what you want (only child pages of page 6) or all the parent pages? Then it should be 'post_parent' => 0
    – Jen
    Commented Nov 21, 2012 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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