Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How can I exclude child posts using wp_query? Given the following architecture:

  • parent 1
    • child 1
    • child 2
  • parent 2
    • child 3
    • child 4

I'd like to only return parent 1 and parent 2, and exclude child 1, 2, 3 and 4.

I've searched high and low for an answer to this question. Nothing surfaces.

share|improve this question
posts don't usually have a hierachy - do you mean pages? – Michael Aug 4 '11 at 17:48
posts do have hierarchical capabilities. – Lee Peterson Aug 4 '11 at 18:05
@LeePeterson Yap it's true. With plugins like CPT UI you can create a custom post type and add the page-attribute to it to make them hierarchical. – Warface May 6 '14 at 11:48

2 Answers 2

use 'post_parent' => 0 in WP_Query to return only parent posts

share|improve this answer
As soon as I posted my question, I found the answer somewhere else online. Thank you for the correct response!! – Lee Peterson Aug 4 '11 at 18:06
but 'post_parent' only works with pages no? What about "posts" on categories? – eveevans Feb 2 at 20:09
@eveevans please ask a new question to get specific help for what you are trying to achieve. – Brady Feb 4 at 10:29

Also you can use 'include_children' => false, instead.

See explanation from the Codex:

include_children (boolean) - Whether or not to include children for hierarchical taxonomies. Defaults to true.

Link -

share|improve this answer
-1 since this is for taxonomies only. Not related to the question. – Jeremy Nov 4 at 16:39

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.