I’m trying to figure out how to query for posts in my hierarchical custom post type, presumably using WP_Query that have child posts. I can get all pages that don’t have children by setting 'post_parent' => 0
in my WP_Query args, but that returns all posts that are not children. I need only posts that have child posts.
2 comments
Comments are closed.
You can use the
post_parent__not_in
parameter:to retrieve child posts of type cpt.
The generated SQL will then include this part:
As far I have understood your requirement, I guess this is what you need.
I have documented the code, please go thru it.