WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I get all children posts regardless of parent.

If you require more info:

The setup I have is like this: I have a custom post type "Project". I will create top level pages as the "main" project page. Then I will have children pages as something like a project blog. Mainly for WIP posts.

I will have a Portfolio page that shows all completed projects, and a "WIP" page showing all WIP posts regardless of project. How can I do this

share|improve this question
up vote 2 down vote accepted

Couple of possible ways.

  1. Use get_pages() with parent => 0 to fetch top-level ones and put them as post__not_in in query.

  2. Filter posts_where to add AND post_parent > 0 when necessary.

share|improve this answer

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.