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 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
add comment

1 Answer

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
add comment

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.