I have a CPT called "Books" and another CPT called "Chapters".
I want to create a view that displays the children "chapter" posts in the parent "book post.
this is very easy and I achieved this.
however, when the book doesn't have children, it gives "no posts found". also, I want to display a header above the chapters list.
therefore, I wanted to use conditional in either of the following ways:
1- if the parent book has a certain category (that i will assign to the books that have chapters), then show the children, or
2- if the parent book has children posts, then display these children.
however, i can't find a way to do either solutions.
i tried this code, but it did not display anything:
The simplest solution to "No posts found" showing when there are no child posts is to edit the child post View and delete that text from the Loop Output Editor so that the wpv-no-items-found shortcode contains nothing, in which case nothing will be output when there are no child posts.
If you want to display a head above the chapters list that appears only when there are chapters, then you can add that header in the same Loop Output Editor of the same child View, immediately after the opening wpv-items-found shortcode (so that it appears when there are child results) but before the wpv-loop tag (so that it only appears once and not for each child post iteration).