Skip Navigation

[Resolved] Display count of child posts related to parent and display in loop view

This thread is resolved. Here is a description of the problem and solution.

Problem:

Two post type:
- Parent post type
- Child post type

One-to-many relationship between above post types "Parent post type" and "Child post type".

I would like to add to this view the count of related children posts each parent has in the loop view.

Solution:

it is possible with a nested view, for example, you can try these:

https://toolset.com/forums/topic/display-count-of-child-posts-related-to-parent-and-display-in-loop-view/#post-1366065

Relevant Documentation:

https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items

https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-found-count

This support ticket is created 5 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by anthonyD-3 5 years ago.

Assisted by: Luo Yang.

Author
Posts
#1365827

Tell us what you are trying to do?
I am trying to display the number of children posts related to a parent but in a loop view. Meaning I have a view that lists the parent posts in a loop. I would like to add to this view the count of related children posts each parent has in the loop view.

For example loop output
Parent Post Title One
Parent Taxonomy
10 Children Posts

Parent Post Title Two
Parent Taxonomy
5 Children Posts

Parent Post Title Three
Parent Taxonomy
2 Children Posts

#1366065

Hello,

I assume we are talking about this case:
Two post type:
- Parent post type
- Child post type

One-to-many relationship between above post types "Parent post type" and "Child post type".

If it is, it is possible with a nested view, for example, you can try these:
1) Parent post view:
- Query "Parent post type" posts
- display "Parent post type" post information + below child post view
2) Child post view
- Query "Child post type",
- Filter by post type relationship between post types "Parent post type" and "Child post type":
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items
- display the post found count shortcode: [wpv-found-count]
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-found-count
description:
Displays the total number of posts, users or taxonomies that have been found by the Views query.

#1369361
Screenshot 2019-10-24 14.47.32.png

Thanks for the quick response the other day. However I am not quite sure how to take your instructions and use the [wpv-found-count] shortcode from the child view created to display the count on the parent views. Can this be done using the directions you outlined above? Please see attachment to see what I am attempting to create.

#1369563

Yes, it can be done as I mentioned above, I have enabled the private message box in case you need more assistance for it.

#1371627

My issue is resolved now. Thank you!