i have a page template as start page(home.php). i use a 2 columns grid to display all pages on that home.php with title and excerpt. unfortunately also my child pages are shown and i can't figure out how to hide them.

I am not trying to make a list menue or something, its more like a gallery of my pages.

for now i use "query_posts('post_type=page' .$parent);" with the mentioned result. i tried to use an array as well, but this will give me posts instead of pages (fr reasons i havnt understood yet). What am i missing to hide all child pages and only display the parent pages? Any help? Thanks in advance! Dan

1 Answer 1


There is a parameter in WP_Query called post_parent. Normally this refers to the ID of the post's parent, but since its an integer field, pages without a parent have in essence a post_parent of 0.

So, to get all pages that are not child pages of another page, you could use

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

or, in array syntax that would be

query_posts( array( 
    'post_type' => 'page',
    'post_parent' => 0 ) );
  • o.k. now i am speechless since i was sure i had tried this and it didn't worked, but i obviously must have done something wrong. your solution works like a charme. Thanks a thousand times!!! the only issue i have now is that the pages are displayed correct, but the order is not the way i used in the main navigation (same pages). i tried to order by count but didnt get this work.. any idea? thans again!
    – Dan
    Commented Dec 29, 2011 at 22:41
  • Try 'orderby' => 'menu_order', 'order' => 'ASC' - that will order the pages by the menu order set in the Page Attributes box. If you're talking about the order you've given them is a custom nav menu, though, there's no easy way to get at that order without a lot of joins and filters... Commented Dec 30, 2011 at 0:30

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.