Exclude Child Posts from WP_Query

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.

1
1

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

Leave a Comment