Hello,
I have two classic views, the first one looping on parents and a second (nested) one looping on children of a one-to-many relationship, output on the page is like this:
PARENT1
CHILD1
CHILD2
CHILD3
PARENT2
CHILD1
CHILD2
PARENT3
No items found
Is there a way not to show parents like PARENT3 which have no children ?
Thanks
Regards
Nicola
Hello Minesh,
In the parent view template I simply call the child view like this:
[wpv-view name="planned-events-events-children"]
Both loops are standard, see below.
The child view has a Filter by post relationship active.
Should I do it differently ?
thanks
Regads
Nicola
Can you please try to follow the following steps:
1)
In the parent view template I simply call the child view like this:
[wpv-view name="planned-events-events-children"]
====>
Please remove the view's shortcode you added to parent view's template and save the parent view.
That means the parent template only called when there is child post found and if found we assign it the parent id using the shortcode: [wpv-attribute name='parentid']
Hello Minesh,
Your solution works, but there is a strange behaviour of the pagination. I set the pagination to max 5 parents per page in the parents view and in output the first page is empty while other pages show one parent only (with correct children) and many other empty pages afterwards. Removing the pagination the output is correct.
Please let me know.
thanks
New threads created by Minesh and linked to this one are listed below:
Unfortunately in this context I need the pagination because parents with children will be many, the page would be VERY long ! any clue ? what about replacing the normal pagination with buttons ?
As per our support policy, we entertain only one question per ticket. This will help other users searching on the forum as well as help us to write correct problem resolution summery.