Take the 2-minute tour ×
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
2  
posts don't usually have a hierachy - do you mean pages? –  Michael Aug 4 '11 at 17:48
2  
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 at 11:48

1 Answer 1

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

Your Answer

 
discard

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.