How to hide all child pages with post_query?

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.

Read More

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

Related posts

Leave a Reply

1 comment

  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 ) );