Problem:
How to list parent posts (and their children) but omit parents that don't have any children?
Solution:
You need an outer View which returns all of the parent posts, which does not output any fields from the parent itself, and only contains the embedded View to return all of the child posts from each parent.
Then in the output of this embedded View you can output both fields of the child posts (directly) and fields from the parent, by using the id attribute (which will be generated automatically if you use the Fields and Views button and the post selection tab). If you want the parent fields to appear only once (not for each child), include them before the opening wpv-loop tag.
In the no-items-found section of this embedded View you output nothing (rather than the normal message).
That way for parents where there are no child posts, nothing will be output.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | - |
- | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | - |
Supporter timezone: Europe/London (GMT+00:00)
This topic contains 4 replies, has 2 voices.
Last updated by 6 years, 4 months ago.
Assisted by: Nigel.